0

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.

Trevz0r
  • 9
  • 1
  • 1
  • 2
  • 2
    There are a few related questions, try searching using 'BCD'. [hexadecimal-to-bcd-conversion](http://stackoverflow.com/a/14293216/97073) & [binary-coded-decimals-in-verilog](http://stackoverflow.com/q/14323107/97073). – Morgan Apr 24 '14 at 11:55
  • I does look like you want us to write your code. Have you simulated this code? What do you mean when you say you are lost? Can you ask a specific question? –  Apr 24 '14 at 14:21
  • @JoeHass So say I have my eight digit binary number, and my four seven segment displays. Display one will be used only for a negative sign, and then display two will be either a one or display nothing. Once I've got my number loaded from the switches, I'm not entirely sure how I can take that input and put it on the last two displays. Like, if I have 0100011 how do I get display three to show a nine and display four to show another nine since that number would be 99? – Trevz0r Apr 24 '14 at 19:11
  • You say you are "not entirely sure", so tell us what you have in mind, what you think might work, what you _are_ sure about. –  Apr 24 '14 at 19:31
  • @JoeHass So I'm sure that I can check the value of my first switch, and if it equals a one I can then make display one be a negative sign, and I'm also certain that if the number is less than one hundred I can leave display two off. What I"m not certain of is how I can then take that remaining number, whatever it may be and display it on the last two displays. – Trevz0r Apr 24 '14 at 20:01
  • The [Basys 3 Reference Sheet](https://reference.digilentinc.com/basys3/refmanual#basic_io) has a very good explanation of how to use the seven segment display. – Kaiser Keister Mar 05 '19 at 08:22

0 Answers0