In order to write programs you need to understand how to manipulate the ROM memory module I recommend you to watch my tutorial. It is long but I tried to explain step by step how I designed the ones shifter:
Additional Controlled datapath information, lab isntructions, next state logic and control words:
Lab sheets:
Each of the components in this design has been tested on the development board:
| CONTROLLER MODULE |
<4 i="i+1)</p">
<4 i="i+1)</p">
ROM MEMORY ONES COUNTER
module ROM_memory(
input [3:0]address,
output reg[1:0]condition_select,
output reg [1:0]Functions,
output reg [20:0]d_out,
output reg done,
output reg[3:0]Branch_ADDRESS_M
);
localparam [3:0]
zero = 4'b0000,
one = 4'b0001,
two = 4'b0010,
three = 4'b0011,
four= 4'b0100,
five = 4'b0101,
six= 4'b0110,
seven= 4'b0111,
eight = 4'b1000,
nine= 4'b1001,
ten= 4'b1010,
eleven = 4'b1011,
twelve = 4'b1100,
thirten= 4'b1101,
fourten= 4'b1110,
fiften= 4'b1111;
always @*
begin
case (address)
zero: d_out = 20'b00000000000000000000;
one: d_out = 20'b10001000000000000000;
two: d_out = 20'b00101011101110100000;
three: d_out = 20'b00011010100001000000;
four: d_out = 20'b00111000100110010000;
five: d_out = 20'b00101010101111010000;
six: d_out = 20'b00001000100010011100;
seven: d_out = 20'b00000010101010010001;
default d_out = 20'b00000000000000000000;
endcase
end
always @*
begin
case (address)
zero: Functions = 2'b01;
one: Functions = 2'b00;
two: Functions = 2'b00;
three: Functions = 2'b00;
four: Functions = 2'b00;
five: Functions = 2'b00;
six: Functions = 2'b11;
seven: Functions = 2'b10;
default Functions = 2'b00;
endcase
end
always @*
begin
case (address)
zero: condition_select = 2'b01;
one: condition_select = 2'b00;
two: condition_select = 2'b00;
three: condition_select = 2'b00;
four: condition_select = 2'b00;
five: condition_select = 2'b00;
six: condition_select = 2'b10;
seven: condition_select = 2'b00;
default condition_select = 2'b00;
endcase
end
always @*
begin
case (address)
zero: done = 1'b0;
one: done = 1'b0;
two: done = 1'b0;
three: done = 1'b0;
four: done = 1'b0;
five: done = 1'b0;
six: done = 1'b0;
seven: done = 1'b1;
default done = 1'b0;
endcase
end
always @*
begin
case (address)
zero: Branch_ADDRESS_M = 4'b0000;
one: Branch_ADDRESS_M = 4'b0000;
two: Branch_ADDRESS_M = 4'b0000;
three: Branch_ADDRESS_M = 4'b0000;
four: Branch_ADDRESS_M = 4'b0000;
five: Branch_ADDRESS_M = 4'b0000;
six: Branch_ADDRESS_M = 4'b0100;
seven: Branch_ADDRESS_M = 4'b0000;
default Branch_ADDRESS_M = 4'b0000;
endcase
end
endmodule
ROM MEMORY ONES SHIFTER
module ROM_memory(
input [3:0]address,
output reg[1:0]condition_select,
output reg [1:0]Functions,
output reg [20:0]d_out,
output reg done,
output reg[3:0]Branch_ADDRESS_M
);
localparam [3:0]
zero = 4'b0000,
one = 4'b0001,
two = 4'b0010,
three = 4'b0011,
four= 4'b0100,
five = 4'b0101,
six= 4'b0110,
seven= 4'b0111,
eight = 4'b1000,
nine= 4'b1001,
ten= 4'b1010,
eleven = 4'b1011,
twelve = 4'b1100,
thirten= 4'b1101,
fourten= 4'b1110,
fiften= 4'b1111;
always @*
begin
case (address)
zero: d_out = 20'b00000000000000000000;
one: d_out = 20'b10001000100010010000;
two: d_out = 20'b00001000100011100000;
three: d_out = 20'b00011001100001000001;
four: d_out = 20'b00011001100110010101;
five: d_out = 20'b00011001100110010101;
six: d_out = 20'b00011001100110010101;
seven: d_out = 20'b00011001100110010001;
eight: d_out = 20'b00011001100110011101;
nine: d_out = 20'b00011001100110011101;
ten: d_out = 20'b00011001100111110000;
eleven: d_out = 20'b00001000100111010000;
twelve: d_out = 20'b00000000100010010000;
default d_out = 20'b00000000000000000000;
endcase
end
always @*
begin
case (address)
zero: Functions = 2'b01;
one: Functions = 2'b00;
two: Functions = 2'b00;
three: Functions = 2'b00;
four: Functions = 2'b00;
five: Functions = 2'b00;
six: Functions = 2'b00;
seven: Functions = 2'b00;
eight: Functions = 2'b00;
nine: Functions = 2'b00;
ten: Functions = 2'b00;
eleven: Functions = 2'b11;
twelve: Functions = 2'b10;
default Functions = 2'b00;
endcase
end
always @*
begin
case (address)
zero: condition_select = 2'b01;
one: condition_select = 2'b10;
two: condition_select = 2'b00;
three: condition_select = 2'b00;
four: condition_select = 2'b00;
five: condition_select = 2'b00;
six: condition_select = 2'b00;
seven: condition_select = 2'b00;
eight: condition_select = 2'b00;
nine: condition_select = 2'b00;
ten: condition_select = 2'b00;
eleven: condition_select = 2'b10;
twelve: condition_select = 2'b00;
default condition_select = 2'b00;
endcase
end
always @*
begin
case (address)
zero: done = 1'b0;
one: done = 1'b0;
two: done = 1'b0;
three: done = 1'b0;
four: done = 1'b0;
five: done = 1'b0;
six: done = 1'b0;
seven: done = 1'b0;
eight: done = 1'b0;
nine: done = 1'b0;
ten: done = 1'b0;
eleven: done = 1'b0;
twelve: done = 1'b1;
default done = 1'b0;
endcase
end
always @*
begin
case (address)
zero: Branch_ADDRESS_M = 4'b0000;
one: Branch_ADDRESS_M = 4'b0000;
two: Branch_ADDRESS_M = 4'b0000;
three: Branch_ADDRESS_M = 4'b0000;
four: Branch_ADDRESS_M = 4'b0000;
five: Branch_ADDRESS_M = 4'b0000;
six: Branch_ADDRESS_M = 4'b0000;
seven: Branch_ADDRESS_M = 4'b0000;
eight: Branch_ADDRESS_M = 4'b0000;
nine: Branch_ADDRESS_M = 4'b0000;
ten: Branch_ADDRESS_M = 4'b0000;
eleven: Branch_ADDRESS_M = 4'b0010;
twelve: Branch_ADDRESS_M = 4'b0000;
default Branch_ADDRESS_M = 4'b0000;
endcase
end
endmodule
CONSTRAINTS
#16I/Os_2 on off switches
NET "start" LOC = "p88" ;
NET "asynchronousreset" LOC = "p87" ;
#NET "alt" LOC = "p86" ;
NET "clk" LOC = "P58" ;
#8I/Os_2 Push switches
NET "datain[0]" LOC = "p94" ;
NET "datain[1]" LOC = "p93" ;
NET "datain[2]" LOC = "p92" ;
NET "datain[3]" LOC = "p91" ;
#16I/Os_1 LEDS
NET "dataout[0]" LOC = "p126" ;
NET "dataout[1]" LOC = "p125" ;
NET "dataout[2]" LOC = "p124" ;
NET "dataout[3]" LOC = "p123" ;
NET "done" LOC = "p52" ;
No comments:
Post a Comment