everyone!
I'm working on my final project here and I find myself getting lost. essentially what I am trying to do is use my Basys board as an 8 bit signed number converter. So there are the eight switches which I pull as inputs to make a signed number such as 10111110. I then want to take that number and convert it to it's equivalent decimal value through 2's compliment. I then want to display the number on my seven-segment displays. I would love any tips or suggestions on how to start because I just can't figure out how I take the number and display it across the displays. I'll post my code and look forward to reading any suggestions you guys have for me. Thanks for the help!
input load, cup, cdown, rst;
input Sw7, Sw6, Sw5, Sw4, Sw3, Sw2, Sw1, Sw0;
output MyNumber[7];
seg7 h1(w, x, y, z, a, b, c, d, e,f,g);
clockdivider h2(clk0, ClkOut);
initial begin
MyNumber <= 8'b0000000;
end
always @(MyNumber)
w <= MyNumber[7]
MyNumber[6]
MyNumber[5]
MyNumber[4]
MyNumber[3]
MyNumber[2]
MyNumber[1]
MyNumber[0]
end
always @(posedge clk) begin
if(rst) begin
MyNumber <=0;
end else if (cup) begin
MyNumber = MyNumber + 1;
end else if (cdown) begin
MyNumber = MyNumber - 1;
end else if (load) begin
MyNumber[7] <= Sw0;
MyNumber[6] <= Sw1;
MyNumber[5] <= Sw2;
MyNumber[4] <= Sw3;
MyNumber[3] <= Sw4;
MyNumber[2] <= Sw5;
MyNumber[1] <= Sw6;
MyNumber[0] <= Sw7;
end
end
And here is my seven segment display code
input w, x, y, z;
output reg a, b, c, d, e,f,g;
reg [6:0] a_to_g;
reg [3:0] w_to_z;
initial begin
w_to_z[3] = w;
w_to_z[2] = x;
w_to_z[1] = y;
w_to_z[0] = z;
a=0;b=0;c=0;d=0;e=0;f=0;g=0;
end
always @(*) begin
w_to_z[3] = w;
w_to_z[2] = x;
w_to_z[1] = y;
w_to_z[0] = z;
case(w_to_z)
0:a_to_g=7'b0000001;
1:a_to_g=7'b1001111;
2:a_to_g=7'b0010010;
3:a_to_g=7'b0000110;
4:a_to_g=7'b1001100;
5:a_to_g=7'b0100100;
6:a_to_g=7'b0100000;
7:a_to_g=7'b0001111;
8:a_to_g=7'b0000000;
9:a_to_g=7'b0000100;
'ha:a_to_g=7'b0001000;
'hb:a_to_g=7'b1100000;
'hc:a_to_g=7'b0110001;
'hd:a_to_g=7'b1000010;
'hf:a_to_g=7'b0111000;
default a_to_g=7'b1111111;
endcase
a = a_to_g[6];
b = a_to_g[5];
c = a_to_g[4];
d = a_to_g[3];
e = a_to_g[2];
f = a_to_g[1];
g = a_to_g[0];
end
And I totally don't want to come off like I'm looking for someone to do my assignment for me. I'm just lost and could use a push in the right direction, thanks everyone.