File tree Expand file tree Collapse file tree 2 files changed +30
-24
lines changed Expand file tree Collapse file tree 2 files changed +30
-24
lines changed Original file line number Diff line number Diff line change 11// Board configuration: tang_nano_9k_lcd_480_272_tm1638_hackathon
2- // This module uses few parameterization and relaxed typing rules
3-
2+ // Updated hackathon_top.sv
43module hackathon_top
54(
65 input logic clock,
@@ -10,13 +9,9 @@ module hackathon_top
109 input logic [7 : 0 ] key,
1110 output logic [7 : 0 ] led,
1211
13- // A dynamic seven-segment display
14-
1512 output logic [7 : 0 ] abcdefgh,
1613 output logic [7 : 0 ] digit,
1714
18- // LCD screen interface
19-
2015 input logic [8 : 0 ] x,
2116 input logic [8 : 0 ] y,
2217
@@ -33,26 +28,28 @@ module hackathon_top
3328
3429 // START_SOLUTION
3530
31+ // For rotary encoder A/B signals
3632 wire a, b;
37-
38- sync_and_debounce # (.w (2 ))
39- i_sync_and_debounce
40- (
41- .clk ( clock ),
42- .reset ( reset ),
43- .sw_in ( gpio [3 : 2 ] ),
44- .sw_out ( { b, a } )
45- );
33+
34+ // Connect A and B directly to gpio pins
35+ assign a = gpio[2 ];
36+ assign b = gpio[3 ];
37+
38+ // Connect switch directly to gpio[0]
39+ wire sw = gpio[0 ]; // Direct connection to GPIO0
4640
4741 wire [15 : 0 ] value;
42+ wire sw_state;
4843
4944 rotary_encoder i_rotary_encoder
5045 (
5146 .clk ( clock ),
5247 .reset ( reset ),
5348 .a ( a ),
5449 .b ( b ),
55- .value ( value )
50+ .value ( value ),
51+ .sw ( sw ), // Direct connection to switch
52+ .sw_state ( sw_state )
5653 );
5754
5855 seven_segment_display
@@ -62,11 +59,12 @@ module hackathon_top
6259 .clk ( clock ),
6360 .rst ( reset ),
6461 .number ( 32 ' (value) ),
65- .dots ( '0 ),
62+ .dots ( { 8 { sw_state }} ), // Control decimal points with switch state
6663 .abcdefgh ( abcdefgh ),
6764 .digit ( digit )
6865 );
6966
70- // END_SOLUTION
67+ // Display switch state on all LEDs
68+ assign led = { 8 { sw_state}} ; // Control LEDs with switch state
7169
72- endmodule
70+ endmodule
Original file line number Diff line number Diff line change 11`include " config.svh"
22
3- // Rotary Encoder Ky-040
4-
53module rotary_encoder
64(
75 input clk,
86 input reset,
97 input a,
108 input b,
11- output logic [15 : 0 ] value
9+ output logic [15 : 0 ] value,
10+ input sw,
11+ output logic sw_state
1212);
1313
1414 logic prev_a;
@@ -22,7 +22,7 @@ module rotary_encoder
2222 always_ff @ (posedge clk)
2323 if (reset)
2424 begin
25- value <= - 16'd1 ; // To do: figure out why we have to start with -1 and not 0
25+ value <= - 16'd1 ;
2626 end
2727 else if (a && ! prev_a)
2828 begin
@@ -32,4 +32,12 @@ module rotary_encoder
3232 value <= value - 16'd1 ;
3333 end
3434
35- endmodule
35+ // Simple switch handling with optional inversion
36+ // Try both options to see which works with your hardware
37+ // Option 1: Direct assignment
38+ assign sw_state = sw;
39+
40+ // Option 2: Inverted (if switch is active-low)
41+ // assign sw_state = !sw;
42+
43+ endmodule
You can’t perform that action at this time.
0 commit comments