Forum | Documentation | Website | Blog

Skip to content
Snippets Groups Projects
Commit 03e3bc79 authored by Vauban's avatar Vauban
Browse files

Cape: Robotics: Add encoders, adjust debounce.

parent 42e49cfd
No related merge requests found
......@@ -83,6 +83,10 @@ sd_connect_pin_to_port -sd_name ${sd_name} -pin_name {CAPE:P9_PIN27} -port_name
sd_connect_pin_to_port -sd_name ${sd_name} -pin_name {CAPE:P8_PIN35} -port_name {}
sd_connect_pin_to_port -sd_name ${sd_name} -pin_name {CAPE:P8_PIN33} -port_name {}
sd_connect_pin_to_port -sd_name ${sd_name} -pin_name {CAPE:P9_PIN42} -port_name {}
sd_connect_pin_to_port -sd_name ${sd_name} -pin_name {CAPE:P8_PIN11} -port_name {}
sd_connect_pin_to_port -sd_name ${sd_name} -pin_name {CAPE:P8_PIN12} -port_name {}
sd_connect_pin_to_port -sd_name ${sd_name} -pin_name {CAPE:P8_PIN15} -port_name {}
sd_connect_pin_to_port -sd_name ${sd_name} -pin_name {CAPE:P8_PIN16} -port_name {}
sd_connect_pins -sd_name ${sd_name} -pin_names {"CAPE:APB_SLAVE" "BVF_RISCV_SUBSYSTEM:CAPE_APB_MTARGET"}
......
......@@ -13,6 +13,13 @@ sd_create_scalar_port -sd_name ${sd_name} -port_name {P8_PIN33} -port_direction
sd_create_scalar_port -sd_name ${sd_name} -port_name {P8_PIN35} -port_direction {IN}
sd_create_scalar_port -sd_name ${sd_name} -port_name {P9_PIN27} -port_direction {IN}
sd_create_scalar_port -sd_name ${sd_name} -port_name {P9_PIN42} -port_direction {IN}
sd_create_scalar_port -sd_name ${sd_name} -port_name {P8_PIN11} -port_direction {IN}
sd_create_scalar_port -sd_name ${sd_name} -port_name {P8_PIN12} -port_direction {IN}
sd_create_scalar_port -sd_name ${sd_name} -port_name {P8_PIN15} -port_direction {IN}
sd_create_scalar_port -sd_name ${sd_name} -port_name {P8_PIN16} -port_direction {IN}
sd_create_scalar_port -sd_name ${sd_name} -port_name {PCLK} -port_direction {IN}
sd_create_scalar_port -sd_name ${sd_name} -port_name {PRESETN} -port_direction {IN}
......@@ -24,11 +31,7 @@ sd_create_scalar_port -sd_name ${sd_name} -port_name {P9_PIN14} -port_direction
sd_create_scalar_port -sd_name ${sd_name} -port_name {P9_PIN16} -port_direction {OUT}
sd_create_scalar_port -sd_name ${sd_name} -port_name {P8_PIN10_USER_LED_7} -port_direction {INOUT} -port_is_pad {1}
sd_create_scalar_port -sd_name ${sd_name} -port_name {P8_PIN11_USER_LED_8} -port_direction {INOUT} -port_is_pad {1}
sd_create_scalar_port -sd_name ${sd_name} -port_name {P8_PIN12_USER_LED_9} -port_direction {INOUT} -port_is_pad {1}
sd_create_scalar_port -sd_name ${sd_name} -port_name {P8_PIN14_USER_LED_11} -port_direction {INOUT} -port_is_pad {1}
sd_create_scalar_port -sd_name ${sd_name} -port_name {P8_PIN15} -port_direction {INOUT} -port_is_pad {1}
sd_create_scalar_port -sd_name ${sd_name} -port_name {P8_PIN16} -port_direction {INOUT} -port_is_pad {1}
sd_create_scalar_port -sd_name ${sd_name} -port_name {P8_PIN17} -port_direction {INOUT} -port_is_pad {1}
sd_create_scalar_port -sd_name ${sd_name} -port_name {P8_PIN18} -port_direction {INOUT} -port_is_pad {1}
sd_create_scalar_port -sd_name ${sd_name} -port_name {P8_PIN20} -port_direction {INOUT} -port_is_pad {1}
......@@ -145,8 +148,6 @@ sd_connect_net_to_pins -sd_name ${sd_name} -net_name {P9_PIN15} -pin_names {"P9_
sd_connect_pins -sd_name ${sd_name} -pin_names {"CAPE_DEFAULT_GPIOS:GPIO_0_PAD" "P8_PIN3_USER_LED_0" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"CAPE_DEFAULT_GPIOS:GPIO_11_PAD" "P8_PIN14_USER_LED_11" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"CAPE_DEFAULT_GPIOS:GPIO_12_PAD" "P8_PIN15" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"CAPE_DEFAULT_GPIOS:GPIO_13_PAD" "P8_PIN16" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"CAPE_DEFAULT_GPIOS:GPIO_14_PAD" "P8_PIN17" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"CAPE_DEFAULT_GPIOS:GPIO_15_PAD" "P8_PIN18" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"CAPE_DEFAULT_GPIOS:GPIO_17_PAD" "P8_PIN20" }
......@@ -167,8 +168,6 @@ sd_connect_pins -sd_name ${sd_name} -pin_names {"CAPE_DEFAULT_GPIOS:GPIO_4_PAD"
sd_connect_pins -sd_name ${sd_name} -pin_names {"CAPE_DEFAULT_GPIOS:GPIO_5_PAD" "P8_PIN8_USER_LED_5" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"CAPE_DEFAULT_GPIOS:GPIO_6_PAD" "P8_PIN9_USER_LED_6" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"CAPE_DEFAULT_GPIOS:GPIO_7_PAD" "P8_PIN10_USER_LED_7" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"CAPE_DEFAULT_GPIOS:GPIO_8_PAD" "P8_PIN11_USER_LED_8" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"CAPE_DEFAULT_GPIOS:GPIO_9_PAD" "P8_PIN12_USER_LED_9" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"P8_GPIO_UPPER_0:GPIO_0_PAD" "P8_PIN31" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"P8_GPIO_UPPER_0:GPIO_10_PAD" "P8_PIN41" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"P8_GPIO_UPPER_0:GPIO_11_PAD" "P8_PIN42" }
......@@ -199,6 +198,11 @@ sd_connect_pins -sd_name ${sd_name} -pin_names {"P9_PIN16" "PWM_0:PWM_1" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"P9_PIN27" "apb_rotary_enc_0:enc0_b" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"P9_PIN42" "apb_rotary_enc_0:enc0_a" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"P8_PIN11" "apb_rotary_enc_0:enc2_b" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"P8_PIN12" "apb_rotary_enc_0:enc2_a" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"P8_PIN15" "apb_rotary_enc_0:enc3_b" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"P8_PIN16" "apb_rotary_enc_0:enc3_a" }
# Add bus net connections
sd_connect_pins -sd_name ${sd_name} -pin_names {"CAPE_DEFAULT_GPIOS:GPIO_IN" "GPIO_IN" }
sd_connect_pins -sd_name ${sd_name} -pin_names {"CAPE_DEFAULT_GPIOS:GPIO_OE" "GPIO_OE" }
......
......@@ -12,11 +12,7 @@ sd_instantiate_macro -sd_name ${sd_name} -macro_name {BIBUF} -instance_name {GPI
sd_instantiate_macro -sd_name ${sd_name} -macro_name {BIBUF} -instance_name {GPIO_5_BIBUF}
sd_instantiate_macro -sd_name ${sd_name} -macro_name {BIBUF} -instance_name {GPIO_6_BIBUF}
sd_instantiate_macro -sd_name ${sd_name} -macro_name {BIBUF} -instance_name {GPIO_7_BIBUF}
sd_instantiate_macro -sd_name ${sd_name} -macro_name {BIBUF} -instance_name {GPIO_8_BIBUF}
sd_instantiate_macro -sd_name ${sd_name} -macro_name {BIBUF} -instance_name {GPIO_9_BIBUF}
sd_instantiate_macro -sd_name ${sd_name} -macro_name {BIBUF} -instance_name {GPIO_11_BIBUF}
sd_instantiate_macro -sd_name ${sd_name} -macro_name {BIBUF} -instance_name {GPIO_12_BIBUF}
sd_instantiate_macro -sd_name ${sd_name} -macro_name {BIBUF} -instance_name {GPIO_13_BIBUF}
sd_instantiate_macro -sd_name ${sd_name} -macro_name {BIBUF} -instance_name {GPIO_14_BIBUF}
sd_instantiate_macro -sd_name ${sd_name} -macro_name {BIBUF} -instance_name {GPIO_15_BIBUF}
sd_instantiate_macro -sd_name ${sd_name} -macro_name {BIBUF} -instance_name {GPIO_17_BIBUF}
......@@ -134,11 +130,7 @@ sd_connect_pins -sd_name {CAPE_DEFAULT_GPIOS} -pin_names {"GPIO_4_BIBUF:D" "GPIO
sd_connect_pins -sd_name {CAPE_DEFAULT_GPIOS} -pin_names {"GPIO_5_BIBUF:D" "GPIO_OUT[5:5]"}
sd_connect_pins -sd_name {CAPE_DEFAULT_GPIOS} -pin_names {"GPIO_6_BIBUF:D" "GPIO_OUT[6:6]"}
sd_connect_pins -sd_name {CAPE_DEFAULT_GPIOS} -pin_names {"GPIO_7_BIBUF:D" "GPIO_OUT[7:7]"}
sd_connect_pins -sd_name {CAPE_DEFAULT_GPIOS} -pin_names {"GPIO_8_BIBUF:D" "GPIO_OUT[8:8]"}
sd_connect_pins -sd_name {CAPE_DEFAULT_GPIOS} -pin_names {"GPIO_9_BIBUF:D" "GPIO_OUT[9:9]"}
sd_connect_pins -sd_name {CAPE_DEFAULT_GPIOS} -pin_names {"GPIO_11_BIBUF:D" "GPIO_OUT[11:11]"}
sd_connect_pins -sd_name {CAPE_DEFAULT_GPIOS} -pin_names {"GPIO_12_BIBUF:D" "GPIO_OUT[12:12]"}
sd_connect_pins -sd_name {CAPE_DEFAULT_GPIOS} -pin_names {"GPIO_13_BIBUF:D" "GPIO_OUT[13:13]"}
sd_connect_pins -sd_name {CAPE_DEFAULT_GPIOS} -pin_names {"GPIO_14_BIBUF:D" "GPIO_OUT[14:14]"}
sd_connect_pins -sd_name {CAPE_DEFAULT_GPIOS} -pin_names {"GPIO_15_BIBUF:D" "GPIO_OUT[15:15]"}
sd_connect_pins -sd_name {CAPE_DEFAULT_GPIOS} -pin_names {"GPIO_17_BIBUF:D" "GPIO_OUT[17:17]"}
......@@ -162,11 +154,7 @@ sd_connect_pins -sd_name {CAPE_DEFAULT_GPIOS} -pin_names {"GPIO_4_BIBUF:E" "GPIO
sd_connect_pins -sd_name {CAPE_DEFAULT_GPIOS} -pin_names {"GPIO_5_BIBUF:E" "GPIO_OE[5:5]"}
sd_connect_pins -sd_name {CAPE_DEFAULT_GPIOS} -pin_names {"GPIO_6_BIBUF:E" "GPIO_OE[6:6]"}
sd_connect_pins -sd_name {CAPE_DEFAULT_GPIOS} -pin_names {"GPIO_7_BIBUF:E" "GPIO_OE[7:7]"}
sd_connect_pins -sd_name {CAPE_DEFAULT_GPIOS} -pin_names {"GPIO_8_BIBUF:E" "GPIO_OE[8:8]"}
sd_connect_pins -sd_name {CAPE_DEFAULT_GPIOS} -pin_names {"GPIO_9_BIBUF:E" "GPIO_OE[9:9]"}
sd_connect_pins -sd_name {CAPE_DEFAULT_GPIOS} -pin_names {"GPIO_11_BIBUF:E" "GPIO_OE[11:11]"}
sd_connect_pins -sd_name {CAPE_DEFAULT_GPIOS} -pin_names {"GPIO_12_BIBUF:E" "GPIO_OE[12:12]"}
sd_connect_pins -sd_name {CAPE_DEFAULT_GPIOS} -pin_names {"GPIO_13_BIBUF:E" "GPIO_OE[13:13]"}
sd_connect_pins -sd_name {CAPE_DEFAULT_GPIOS} -pin_names {"GPIO_14_BIBUF:E" "GPIO_OE[14:14]"}
sd_connect_pins -sd_name {CAPE_DEFAULT_GPIOS} -pin_names {"GPIO_15_BIBUF:E" "GPIO_OE[15:15]"}
sd_connect_pins -sd_name {CAPE_DEFAULT_GPIOS} -pin_names {"GPIO_17_BIBUF:E" "GPIO_OE[17:17]"}
......@@ -190,11 +178,7 @@ sd_connect_pins -sd_name {CAPE_DEFAULT_GPIOS} -pin_names {"GPIO_4_BIBUF:Y" "GPIO
sd_connect_pins -sd_name {CAPE_DEFAULT_GPIOS} -pin_names {"GPIO_5_BIBUF:Y" "GPIO_IN[5:5]"}
sd_connect_pins -sd_name {CAPE_DEFAULT_GPIOS} -pin_names {"GPIO_6_BIBUF:Y" "GPIO_IN[6:6]"}
sd_connect_pins -sd_name {CAPE_DEFAULT_GPIOS} -pin_names {"GPIO_7_BIBUF:Y" "GPIO_IN[7:7]"}
sd_connect_pins -sd_name {CAPE_DEFAULT_GPIOS} -pin_names {"GPIO_8_BIBUF:Y" "GPIO_IN[8:8]"}
sd_connect_pins -sd_name {CAPE_DEFAULT_GPIOS} -pin_names {"GPIO_9_BIBUF:Y" "GPIO_IN[9:9]"}
sd_connect_pins -sd_name {CAPE_DEFAULT_GPIOS} -pin_names {"GPIO_11_BIBUF:Y" "GPIO_IN[11:11]"}
sd_connect_pins -sd_name {CAPE_DEFAULT_GPIOS} -pin_names {"GPIO_12_BIBUF:Y" "GPIO_IN[12:12]"}
sd_connect_pins -sd_name {CAPE_DEFAULT_GPIOS} -pin_names {"GPIO_13_BIBUF:Y" "GPIO_IN[13:13]"}
sd_connect_pins -sd_name {CAPE_DEFAULT_GPIOS} -pin_names {"GPIO_14_BIBUF:Y" "GPIO_IN[14:14]"}
sd_connect_pins -sd_name {CAPE_DEFAULT_GPIOS} -pin_names {"GPIO_15_BIBUF:Y" "GPIO_IN[15:15]"}
sd_connect_pins -sd_name {CAPE_DEFAULT_GPIOS} -pin_names {"GPIO_17_BIBUF:Y" "GPIO_IN[17:17]"}
......@@ -218,24 +202,27 @@ sd_rename_port -sd_name {CAPE_DEFAULT_GPIOS} -current_port_name {PAD_3} -new_por
sd_rename_port -sd_name {CAPE_DEFAULT_GPIOS} -current_port_name {PAD_4} -new_port_name {GPIO_5_PAD}
sd_rename_port -sd_name {CAPE_DEFAULT_GPIOS} -current_port_name {PAD_5} -new_port_name {GPIO_6_PAD}
sd_rename_port -sd_name {CAPE_DEFAULT_GPIOS} -current_port_name {PAD_6} -new_port_name {GPIO_7_PAD}
sd_rename_port -sd_name {CAPE_DEFAULT_GPIOS} -current_port_name {PAD_7} -new_port_name {GPIO_8_PAD}
sd_rename_port -sd_name {CAPE_DEFAULT_GPIOS} -current_port_name {PAD_8} -new_port_name {GPIO_9_PAD}
sd_rename_port -sd_name {CAPE_DEFAULT_GPIOS} -current_port_name {PAD_9} -new_port_name {GPIO_11_PAD}
sd_rename_port -sd_name {CAPE_DEFAULT_GPIOS} -current_port_name {PAD_10} -new_port_name {GPIO_12_PAD}
sd_rename_port -sd_name {CAPE_DEFAULT_GPIOS} -current_port_name {PAD_11} -new_port_name {GPIO_13_PAD}
sd_rename_port -sd_name {CAPE_DEFAULT_GPIOS} -current_port_name {PAD_12} -new_port_name {GPIO_14_PAD}
sd_rename_port -sd_name {CAPE_DEFAULT_GPIOS} -current_port_name {PAD_13} -new_port_name {GPIO_15_PAD}
sd_rename_port -sd_name {CAPE_DEFAULT_GPIOS} -current_port_name {PAD_14} -new_port_name {GPIO_17_PAD}
sd_rename_port -sd_name {CAPE_DEFAULT_GPIOS} -current_port_name {PAD_15} -new_port_name {GPIO_18_PAD}
sd_rename_port -sd_name {CAPE_DEFAULT_GPIOS} -current_port_name {PAD_16} -new_port_name {GPIO_19_PAD}
sd_rename_port -sd_name {CAPE_DEFAULT_GPIOS} -current_port_name {PAD_17} -new_port_name {GPIO_20_PAD}
sd_rename_port -sd_name {CAPE_DEFAULT_GPIOS} -current_port_name {PAD_18} -new_port_name {GPIO_21_PAD}
sd_rename_port -sd_name {CAPE_DEFAULT_GPIOS} -current_port_name {PAD_19} -new_port_name {GPIO_22_PAD}
sd_rename_port -sd_name {CAPE_DEFAULT_GPIOS} -current_port_name {PAD_20} -new_port_name {GPIO_23_PAD}
sd_rename_port -sd_name {CAPE_DEFAULT_GPIOS} -current_port_name {PAD_21} -new_port_name {GPIO_24_PAD}
sd_rename_port -sd_name {CAPE_DEFAULT_GPIOS} -current_port_name {PAD_22} -new_port_name {GPIO_25_PAD}
sd_rename_port -sd_name {CAPE_DEFAULT_GPIOS} -current_port_name {PAD_23} -new_port_name {GPIO_26_PAD}
sd_rename_port -sd_name {CAPE_DEFAULT_GPIOS} -current_port_name {PAD_24} -new_port_name {GPIO_27_PAD}
sd_rename_port -sd_name {CAPE_DEFAULT_GPIOS} -current_port_name {PAD_7} -new_port_name {GPIO_11_PAD}
sd_rename_port -sd_name {CAPE_DEFAULT_GPIOS} -current_port_name {PAD_8} -new_port_name {GPIO_14_PAD}
sd_rename_port -sd_name {CAPE_DEFAULT_GPIOS} -current_port_name {PAD_9} -new_port_name {GPIO_15_PAD}
sd_rename_port -sd_name {CAPE_DEFAULT_GPIOS} -current_port_name {PAD_10} -new_port_name {GPIO_17_PAD}
sd_rename_port -sd_name {CAPE_DEFAULT_GPIOS} -current_port_name {PAD_11} -new_port_name {GPIO_18_PAD}
sd_rename_port -sd_name {CAPE_DEFAULT_GPIOS} -current_port_name {PAD_12} -new_port_name {GPIO_19_PAD}
sd_rename_port -sd_name {CAPE_DEFAULT_GPIOS} -current_port_name {PAD_13} -new_port_name {GPIO_20_PAD}
sd_rename_port -sd_name {CAPE_DEFAULT_GPIOS} -current_port_name {PAD_14} -new_port_name {GPIO_21_PAD}
sd_rename_port -sd_name {CAPE_DEFAULT_GPIOS} -current_port_name {PAD_15} -new_port_name {GPIO_22_PAD}
sd_rename_port -sd_name {CAPE_DEFAULT_GPIOS} -current_port_name {PAD_16} -new_port_name {GPIO_23_PAD}
sd_rename_port -sd_name {CAPE_DEFAULT_GPIOS} -current_port_name {PAD_17} -new_port_name {GPIO_24_PAD}
sd_rename_port -sd_name {CAPE_DEFAULT_GPIOS} -current_port_name {PAD_18} -new_port_name {GPIO_25_PAD}
sd_rename_port -sd_name {CAPE_DEFAULT_GPIOS} -current_port_name {PAD_19} -new_port_name {GPIO_26_PAD}
sd_rename_port -sd_name {CAPE_DEFAULT_GPIOS} -current_port_name {PAD_20} -new_port_name {GPIO_27_PAD}
sd_connect_pins_to_constant -sd_name ${sd_name} -pin_names {GPIO_IN[8:8]} -value {GND}
sd_connect_pins_to_constant -sd_name ${sd_name} -pin_names {GPIO_IN[9:9]} -value {GND}
sd_connect_pins_to_constant -sd_name ${sd_name} -pin_names {GPIO_IN[12:12]} -value {GND}
sd_connect_pins_to_constant -sd_name ${sd_name} -pin_names {GPIO_IN[13:13]} -value {GND}
sd_connect_pins_to_constant -sd_name ${sd_name} -pin_names {GPIO_IN[10:10]} -value {GND}
sd_connect_pins_to_constant -sd_name ${sd_name} -pin_names {GPIO_IN[16:16]} -value {GND}
......
......@@ -15,35 +15,99 @@ module apb_rotary_enc
input enc0_a,
input enc0_b,
input enc1_a,
input enc1_b
input enc1_b,
input enc2_a,
input enc2_b,
input enc3_a,
input enc3_b
);
reg [7:0] ctrl_reg;
reg [31:0] apb_read_value;
reg [1:0] sync_enc0_a;
reg [1:0] sync_enc0_b;
reg [1:0] sync_enc1_a;
reg [1:0] sync_enc1_b;
reg [1:0] sync_enc2_a;
reg [1:0] sync_enc2_b;
reg [1:0] sync_enc3_a;
reg [1:0] sync_enc3_b;
wire enc0_a_synced;
wire enc0_b_synced;
wire enc1_a_synced;
wire enc1_b_synced;
wire enc2_a_synced;
wire enc2_b_synced;
wire enc3_a_synced;
wire enc3_b_synced;
assign enc0_a_synced = sync_enc0_a[1];
assign enc0_b_synced = sync_enc0_b[1];
assign enc1_a_synced = sync_enc1_a[1];
assign enc1_b_synced = sync_enc1_b[1];
assign enc2_a_synced = sync_enc2_a[1];
assign enc2_b_synced = sync_enc2_b[1];
assign enc3_a_synced = sync_enc3_a[1];
assign enc3_b_synced = sync_enc3_b[1];
wire write_from_apb;
wire [9:0] cmd_index;
wire [31:0] cmd_word;
assign pslverr = 1'b0;
assign pready= 1'b1;
assign prdata= apb_read_value;;
assign prdata= apb_read_value;
wire [31:0] count0;
wire [31:0] count1;
wire [31:0] count2;
wire [31:0] count3;
wire enc_clk;
wire debounced_enc0_a;
wire debounced_enc0_b;
wire debounced_enc1_a;
wire debounced_enc1_b;
wire debounced_enc2_a;
wire debounced_enc2_b;
wire debounced_enc3_a;
wire debounced_enc3_b;
reg [1:0] counter;
assign enc_clk = counter[1];
//---------------------------------------------------------------------------
always @(negedge pclk)
always @(posedge pclk or negedge presetn)
begin
if(~presetn)
begin
sync_enc0_a <= 2'b0;
sync_enc0_b <= 2'b0;
sync_enc1_a <= 2'b0;
sync_enc1_b <= 2'b0;
sync_enc2_a <= 2'b0;
sync_enc2_b <= 2'b0;
sync_enc3_a <= 2'b0;
sync_enc3_b <= 2'b0;
end
else
begin
sync_enc0_a <= {sync_enc0_a[0], enc0_a};
sync_enc0_b <= {sync_enc0_b[0], enc0_b};
sync_enc1_a <= {sync_enc1_a[0], enc1_a};
sync_enc1_b <= {sync_enc1_b[0], enc1_b};
sync_enc2_a <= {sync_enc2_a[0], enc2_a};
sync_enc2_b <= {sync_enc2_b[0], enc2_b};
sync_enc3_a <= {sync_enc3_a[0], enc3_a};
sync_enc3_b <= {sync_enc3_b[0], enc3_b};
end
end
//---------------------------------------------------------------------------
always @(posedge pclk)
begin
counter <= counter + 1;
end
......@@ -52,31 +116,59 @@ module apb_rotary_enc
debounce debounce_0a
(
.clk(enc_clk),
.switch_in(enc0_a),
.switch_in(enc0_a_synced),
.switch_out(debounced_enc0_a)
);
debounce debounce_0b
(
.clk(enc_clk),
.switch_in(enc0_b),
.switch_in(enc0_b_synced),
.switch_out(debounced_enc0_b)
);
debounce debounce_1a
(
.clk(enc_clk),
.switch_in(enc1_a),
.switch_in(enc1_a_synced),
.switch_out(debounced_enc1_a)
);
debounce debounce_1b
(
.clk(enc_clk),
.switch_in(enc1_b),
.switch_in(enc1_b_synced),
.switch_out(debounced_enc1_b)
);
debounce debounce_2a
(
.clk(enc_clk),
.switch_in(enc2_a_synced),
.switch_out(debounced_enc2_a)
);
debounce debounce_2b
(
.clk(enc_clk),
.switch_in(enc2_b_synced),
.switch_out(debounced_enc2_b)
);
debounce debounce_3a
(
.clk(enc_clk),
.switch_in(enc3_a_synced),
.switch_out(debounced_enc3_a)
);
debounce debounce_3b
(
.clk(enc_clk),
.switch_in(enc3_b_synced),
.switch_out(debounced_enc3_b)
);
//---------------------------------------------------------------------------
rotary_encoder rotary_encoder0
(
......@@ -98,14 +190,41 @@ module apb_rotary_enc
);
//---------------------------------------------------------------------------
always @(negedge pclk)
begin
case (paddr)
8'h00: apb_read_value <= count0;
8'h10: apb_read_value <= count1;
default: apb_read_value <= 32'h00000000;
endcase
end
rotary_encoder rotary_encoder2
(
.clk(enc_clk),
.reset_n(presetn),
.in_a(debounced_enc2_a),
.in_b(debounced_enc2_b),
.count(count2)
);
//---------------------------------------------------------------------------
rotary_encoder rotary_encoder3
(
.clk(enc_clk),
.reset_n(presetn),
.in_a(debounced_enc3_a),
.in_b(debounced_enc3_b),
.count(count3)
);
//---------------------------------------------------------------------------
always @(posedge pclk)
if(~presetn)
begin
apb_read_value <= 32'h00000000;
end
else
begin
case (paddr)
8'h00: apb_read_value <= count0;
8'h10: apb_read_value <= count1;
8'h20: apb_read_value <= count2;
8'h30: apb_read_value <= count3;
default: apb_read_value <= 32'h00000000;
endcase
end
endmodule
......@@ -9,7 +9,7 @@ module debounce
output reg switch_out
);
localparam bounce_limit_upper_bit = 13;
localparam bounce_limit_upper_bit = 8;
reg [bounce_limit_upper_bit:0] bounce_count = 0;
//---------------------------------------------------------------------------
......
# Robotics Cape
This cape gateware includes 4 quadrature decoders. The value for these decoders can be read from the physical addresses in the table below:
| Encoder pins (a/b) | Address of encoder value register |
|---|---|
| P9_42/P9_27 | 0x41300000 |
| P8_35/P8_33 | 0x41300010 |
| P8_12/P8_11 | 0x41300020 |
| P8_16/P8_15 | 0x41300030 |
## P8 Header
| Signal | Control | Irq # | Description |
|--------|----------------------------|-------|-------------|
| P8_1 | n/a | n/a | GND |
| P8_2 | n/a | n/a | GND |
| P8_3 | MSS GPIO_2[0] | 53 | User LED 0 |
| P8_4 | MSS GPIO_2[1] | 53 | User LED 1 |
| P8_5 | MSS GPIO_2[2] | 53 | User LED 2 |
| P8_6 | MSS GPIO_2[3] | 53 | User LED 3 |
| P8_7 | MSS GPIO_2[4] | 53 | User LED 4 |
| P8_8 | MSS GPIO_2[5] | 53 | User LED 5 |
| P8_9 | MSS GPIO_2[6] | 53 | User LED 6 |
| P8_10 | MSS GPIO_2[7] | 53 | User LED 7 |
| P8_11 | MSS GPIO_2[8] | 53 | User LED 8 |
| P8_12 | MSS GPIO_2[9] | 53 | User LED 9 |
| P8_13 | core_pwm[1] @ 0x41500000 | n/a | PWM_2:1 |
| P8_14 | MSS GPIO_2[11] | 53 | User LED 11 |
| P8_15 | MSS GPIO_2[12] | 53 | GPIO |
| P8_16 | MSS GPIO_2[13] | 53 | GPIO |
| P8_17 | MSS GPIO_2[14] | 53 | GPIO |
| P8_18 | MSS GPIO_2[15] | 53 | GPIO |
| P8_19 | core_pwm[0] @ 0x41500000 | n/a | PWM_2:0 |
| P8_20 | MSS GPIO_2[17] | 53 | GPIO |
| P8_21 | MSS GPIO_2[18] | 53 | GPIO |
| P8_22 | MSS GPIO_2[19] | 53 | GPIO |
| P8_23 | MSS GPIO_2[20] | 53 | GPIO |
| P8_24 | MSS GPIO_2[21] | 53 | GPIO |
| P8_25 | MSS GPIO_2[22] | 53 | GPIO |
| P8_26 | MSS GPIO_2[23] | 53 | GPIO |
| P8_27 | MSS GPIO_2[24] | 53 | GPIO |
| P8_28 | MSS GPIO_2[25] | 53 | GPIO |
| P8_29 | MSS GPIO_2[26] | 53 | GPIO |
| P8_30 | MSS GPIO_2[27] | 53 | GPIO |
| P8_31 | core_gpio[0] @ 0x41100000 | 126 | GPIO |
| P8_32 | core_gpio[1] @ 0x41100000 | 127 | GPIO |
| P8_33 | core_gpio[2] @ 0x41100000 | 128 | GPIO |
| P8_34 | core_gpio[3] @ 0x41100000 | 129 | GPIO |
| P8_35 | core_gpio[4] @ 0x41100000 | 130 | GPIO |
| P8_36 | core_gpio[5] @ 0x41100000 | 131 | GPIO |
| P8_37 | core_gpio[6] @ 0x41100000 | 132 | GPIO |
| P8_38 | core_gpio[7] @ 0x41100000 | 133 | GPIO |
| P8_39 | core_gpio[8] @ 0x41100000 | 134 | GPIO |
| P8_40 | core_gpio[9] @ 0x41100000 | 135 | GPIO |
| P8_41 | core_gpio[10] @ 0x41100000 | 136 | GPIO |
| P8_42 | core_gpio[11] @ 0x41100000 | 137 | GPIO |
| P8_43 | core_gpio[12] @ 0x41100000 | 138 | GPIO |
| P8_44 | core_gpio[13] @ 0x41100000 | 139 | GPIO |
| P8_45 | core_gpio[14] @ 0x41100000 | 140 | GPIO |
| P8_46 | core_gpio[15] @ 0x41100000 | 141 | GPIO |
| Signal | Control | Irq # | Description |
|--------|----------------------------|-------|--------------------|
| P8_1 | n/a | n/a | GND |
| P8_2 | n/a | n/a | GND |
| P8_3 | MSS GPIO_2[0] | 53 | User LED 0 |
| P8_4 | MSS GPIO_2[1] | 53 | User LED 1 |
| P8_5 | MSS GPIO_2[2] | 53 | User LED 2 |
| P8_6 | MSS GPIO_2[3] | 53 | User LED 3 |
| P8_7 | MSS GPIO_2[4] | 53 | User LED 4 |
| P8_8 | MSS GPIO_2[5] | 53 | User LED 5 |
| P8_9 | MSS GPIO_2[6] | 53 | User LED 6 |
| P8_10 | MSS GPIO_2[7] | 53 | User LED 7 |
| P8_11 | MSS GPIO_2[8] | 53 | User LED 8 |
| P8_12 | MSS GPIO_2[9] | 53 | User LED 9 |
| P8_13 | core_pwm[1] @ 0x41500000 | n/a | PWM_2:1 |
| P8_14 | MSS GPIO_2[11] | 53 | User LED 11 |
| P8_15 | MSS GPIO_2[12] | 53 | GPIO |
| P8_16 | MSS GPIO_2[13] | 53 | GPIO |
| P8_17 | MSS GPIO_2[14] | 53 | GPIO |
| P8_18 | MSS GPIO_2[15] | 53 | GPIO |
| P8_19 | core_pwm[0] @ 0x41500000 | n/a | PWM_2:0 |
| P8_20 | MSS GPIO_2[17] | 53 | GPIO |
| P8_21 | MSS GPIO_2[18] | 53 | GPIO |
| P8_22 | MSS GPIO_2[19] | 53 | GPIO |
| P8_23 | MSS GPIO_2[20] | 53 | GPIO |
| P8_24 | MSS GPIO_2[21] | 53 | GPIO |
| P8_25 | MSS GPIO_2[22] | 53 | GPIO |
| P8_26 | MSS GPIO_2[23] | 53 | GPIO |
| P8_27 | MSS GPIO_2[24] | 53 | GPIO |
| P8_28 | MSS GPIO_2[25] | 53 | GPIO |
| P8_29 | MSS GPIO_2[26] | 53 | GPIO |
| P8_30 | MSS GPIO_2[27] | 53 | GPIO |
| P8_31 | core_gpio[0] @ 0x41100000 | 126 | GPIO |
| P8_32 | core_gpio[1] @ 0x41100000 | 127 | GPIO |
| P8_33 | Read value @ 0x41300010 | n/a | Encoder1[B] input |
| P8_34 | core_gpio[3] @ 0x41100000 | 129 | GPIO |
| P8_35 | Read value @ 0x41300010 | n/a | Encoder1[A] input |
| P8_36 | core_gpio[5] @ 0x41100000 | 131 | GPIO |
| P8_37 | core_gpio[6] @ 0x41100000 | 132 | GPIO |
| P8_38 | core_gpio[7] @ 0x41100000 | 133 | GPIO |
| P8_39 | core_gpio[8] @ 0x41100000 | 134 | GPIO |
| P8_40 | core_gpio[9] @ 0x41100000 | 135 | GPIO |
| P8_41 | core_gpio[10] @ 0x41100000 | 136 | GPIO |
| P8_42 | core_gpio[11] @ 0x41100000 | 137 | GPIO |
| P8_43 | core_gpio[12] @ 0x41100000 | 138 | GPIO |
| P8_44 | core_gpio[13] @ 0x41100000 | 139 | GPIO |
| P8_45 | core_gpio[14] @ 0x41100000 | 140 | GPIO |
| P8_46 | core_gpio[15] @ 0x41100000 | 141 | GPIO |
## P9 Header
| Signal | Control | Irq # | Description |
|--------|----------------------------|-------|-------------|
| P9_1 | n/a | n/a | GND |
| P9_2 | n/a | n/a | GND |
| P9_3 | n/a | n/a | VCC 3.3V |
| P9_4 | n/a | n/a | VCC 3.3V |
| P9_5 | n/a | n/a | VDD 5V |
| P9_6 | n/a | n/a | VDD 5V |
| P9_7 | n/a | n/a | SYS 5V |
| P9_8 | n/a | n/a | SYS 5V |
| P9_9 | n/a | n/a | NC |
| P9_10 | n/a | n/a | SYS_RSTN |
| P9_11 | | | |
| P9_12 | core_gpio[0] @ 0x41200000 | 142 | GPIO |
| P9_13 | core_gpio[7] @ 0x41200000 | 149 | GPIO |
| P9_14 | core_pwm[0] @ 0x41400000 | n/a | PWM_1:0 |
| P9_15 | core_gpio[1] @ 0x41200000 | 143 | GPIO |
| P9_16 | core_pwm[1] @ 0x41400000 | n/a | PWM_1:1 |
| P9_17 | | | |
| P9_18 | | | |
| P9_19 | MSS I2C0 | 58 | I2C0 SCL |
| P9_20 | MSS I2C0 | 58 | I2C0 SDA |
| P9_21 | | | |
| P9_22 | | | |
| P9_23 | core_gpio[2] @ 0x41200000 | 144 | GPIO |
| P9_24 | | | |
| P9_25 | core_gpio[3] @ 0x41200000 | 145 | GPIO |
| P9_26 | | | |
| P9_27 | | | |
| P9_28 | | | |
| P9_29 | | | |
| P9_30 | core_gpio[5] @ 0x41200000 | 147 | GPIO |
| P9_31 | | | |
| P9_32 | n/a | n/a | VDD ADC |
| P9_33 | n/a | n/a | ADC input 4 |
| P9_34 | n/a | n/a | AGND |
| P9_35 | n/a | n/a | ADC input 6 |
| P9_36 | n/a | n/a | ADC input 5 |
| P9_37 | n/a | n/a | ADC input 2 |
| P9_38 | n/a | n/a | ADC input 3 |
| P9_39 | n/a | n/a | ADC input 0 |
| P9_40 | n/a | n/a | ADC input 1 |
| P9_41 | core_gpio[6] @ 0x41200000 | 148 | GPIO |
| P9_42 | | | |
| P9_43 | n/a | n/a | GND |
| P9_44 | n/a | n/a | GND |
| P9_45 | n/a | n/a | GND |
| P9_46 | n/a | n/a | GND |
| Signal | Control | Irq # | Description |
|--------|----------------------------|-------|-------------------|
| P9_1 | n/a | n/a | GND |
| P9_2 | n/a | n/a | GND |
| P9_3 | n/a | n/a | VCC 3.3V |
| P9_4 | n/a | n/a | VCC 3.3V |
| P9_5 | n/a | n/a | VDD 5V |
| P9_6 | n/a | n/a | VDD 5V |
| P9_7 | n/a | n/a | SYS 5V |
| P9_8 | n/a | n/a | SYS 5V |
| P9_9 | n/a | n/a | NC |
| P9_10 | n/a | n/a | SYS_RSTN |
| P9_11 | | | |
| P9_12 | core_gpio[0] @ 0x41200000 | 142 | GPIO |
| P9_13 | core_gpio[7] @ 0x41200000 | 149 | GPIO |
| P9_14 | core_pwm[0] @ 0x41400000 | n/a | PWM_1:0 |
| P9_15 | core_gpio[1] @ 0x41200000 | 143 | GPIO |
| P9_16 | core_pwm[1] @ 0x41400000 | n/a | PWM_1:1 |
| P9_17 | | | |
| P9_18 | | | |
| P9_19 | MSS I2C0 | 58 | I2C0 SCL |
| P9_20 | MSS I2C0 | 58 | I2C0 SDA |
| P9_21 | | | |
| P9_22 | | | |
| P9_23 | core_gpio[2] @ 0x41200000 | 144 | GPIO |
| P9_24 | | | |
| P9_25 | core_gpio[3] @ 0x41200000 | 145 | GPIO |
| P9_26 | | | |
| P9_27 | Read value @ 0x41300000 | n/a | Encoder0[B] input |
| P9_28 | | | |
| P9_29 | | | |
| P9_30 | core_gpio[5] @ 0x41200000 | 147 | GPIO |
| P9_31 | | | |
| P9_32 | n/a | n/a | VDD ADC |
| P9_33 | n/a | n/a | ADC input 4 |
| P9_34 | n/a | n/a | AGND |
| P9_35 | n/a | n/a | ADC input 6 |
| P9_36 | n/a | n/a | ADC input 5 |
| P9_37 | n/a | n/a | ADC input 2 |
| P9_38 | n/a | n/a | ADC input 3 |
| P9_39 | n/a | n/a | ADC input 0 |
| P9_40 | n/a | n/a | ADC input 1 |
| P9_41 | core_gpio[6] @ 0x41200000 | 148 | GPIO |
| P9_42 | Read value @ 0x41300000 | n/a | Encoder0[A] input |
| P9_43 | n/a | n/a | GND |
| P9_44 | n/a | n/a | GND |
| P9_45 | n/a | n/a | GND |
| P9_46 | n/a | n/a | GND |
......@@ -129,19 +129,17 @@ set_io -port_name P8_PIN10_USER_LED_7 \
-RES_PULL None \
-DIRECTION INOUT
set_io -port_name P8_PIN11_USER_LED_8 \
set_io -port_name P8_PIN11 \
-pin_name Y21 \
-fixed true \
-OUT_DRIVE 12 \
-RES_PULL None \
-DIRECTION INOUT
-DIRECTION IN
set_io -port_name P8_PIN12_USER_LED_9 \
set_io -port_name P8_PIN12 \
-pin_name Y20 \
-fixed true \
-OUT_DRIVE 12 \
-RES_PULL None \
-DIRECTION INOUT
-DIRECTION IN
set_io -port_name P8_PIN13_USER_LED_10 \
-pin_name B10 \
......@@ -163,16 +161,14 @@ set_io -port_name P8_PIN14_USER_LED_11 \
set_io -port_name P8_PIN15 \
-pin_name T12 \
-fixed true \
-OUT_DRIVE 12 \
-RES_PULL None \
-DIRECTION INOUT
-DIRECTION IN
set_io -port_name P8_PIN16 \
-pin_name U12 \
-fixed true \
-OUT_DRIVE 12 \
-RES_PULL None \
-DIRECTION INOUT
-DIRECTION IN
set_io -port_name P8_PIN17 \
-pin_name W13 \
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment