To control the 4 digit seven segment LED's on the Basys3 I need to mux the data by controlling the anode signal.
I made a counter: (possibly a terrible resource hungry counter)
seg_mux_clk: process(clk_240)--cycle through the 4 sev seg displays
begin
if rising_edge(clk_240) then
cnt <= (cnt + 1)mod 4;
end if;
end process;
next I have my one hot logic which I have recently decided to change. I have nothing to back this up but I suspect that the FPGA can more easily handle shifting a bit than it could handle multiplying a number. Believing the shift requires less logic also makes me think its overall better for timing. What you do you guys think?
old version:
an_i <= not std_logic_vector(to_unsigned(2 ** cnt,an_i'length));
New version:
an_i <= not std_logic_vector(shift_left(to_unsigned(1,an_i'length) ,cnt));
PS if you are wondering why I don't just have a process that uses cnt as an unsigned, set cnt to 1 and mulitply it by 2 each clock cycle (1,2,4,8,1,2,4,8,....) , its because my displayed data is an array. This keeps my data and the proper seven segment in sync.
seven_seg_out_reg: process(clk_240)
begin
if rising_edge (clk_240) then
seg <= display(cnt);
an <= an_i;
end if;
end process;
Question
FlyingBlindOnARocketCycle
To control the 4 digit seven segment LED's on the Basys3 I need to mux the data by controlling the anode signal.
I made a counter: (possibly a terrible resource hungry counter)
seg_mux_clk: process(clk_240)--cycle through the 4 sev seg displays
begin
if rising_edge(clk_240) then
cnt <= (cnt + 1)mod 4;
end if;
end process;
next I have my one hot logic which I have recently decided to change. I have nothing to back this up but I suspect that the FPGA can more easily handle shifting a bit than it could handle multiplying a number. Believing the shift requires less logic also makes me think its overall better for timing. What you do you guys think?
old version:
an_i <= not std_logic_vector(to_unsigned(2 ** cnt,an_i'length));
New version:
an_i <= not std_logic_vector(shift_left(to_unsigned(1,an_i'length) ,cnt));
PS if you are wondering why I don't just have a process that uses cnt as an unsigned, set cnt to 1 and mulitply it by 2 each clock cycle (1,2,4,8,1,2,4,8,....) , its because my displayed data is an array. This keeps my data and the proper seven segment in sync.
seven_seg_out_reg: process(clk_240)
begin
if rising_edge (clk_240) then
seg <= display(cnt);
an <= an_i;
end if;
end process;
Link to comment
Share on other sites
1 answer to this question
Recommended Posts
Archived
This topic is now archived and is closed to further replies.