M
Mahurshi Akilla
Guest
i am sort of a newbie, and the code i wrote in my school wasn't that
good (most of it was gate level and some behaviroal code that i never
really had time to improve on).
i want to start anew building good habits, now that i have time (and no
deadlines with assignments.)
i am trying to build a clocked adder. at every positive clock edge, it
will add the two inputs and store the output in a register.
the code i have written is as follows:
module simiple_adder_clked(a, b, clk, sum);
input [7:0] a;
input [7:0] b;
input clk;
output [8:0] sum;
reg [8:0] sum;
always @(posedge clk)
begin
sum <= a + b;
end
endmodule
i have simulated this and this "works"
the questions i have are:
1. is this code "correct"? (verilog rules wise)
2. is there anything i could have done better?
3. is this the right way of doing this? (design/synthesis wise)
4. what does this synthesize to?
5. this is relatively simple i guess. but i still couldn't figure
out. how do i take the MSB of sum and send it out seperately into a
"cout" output.
good (most of it was gate level and some behaviroal code that i never
really had time to improve on).
i want to start anew building good habits, now that i have time (and no
deadlines with assignments.)
i am trying to build a clocked adder. at every positive clock edge, it
will add the two inputs and store the output in a register.
the code i have written is as follows:
module simiple_adder_clked(a, b, clk, sum);
input [7:0] a;
input [7:0] b;
input clk;
output [8:0] sum;
reg [8:0] sum;
always @(posedge clk)
begin
sum <= a + b;
end
endmodule
i have simulated this and this "works"
the questions i have are:
1. is this code "correct"? (verilog rules wise)
2. is there anything i could have done better?
3. is this the right way of doing this? (design/synthesis wise)
4. what does this synthesize to?
5. this is relatively simple i guess. but i still couldn't figure
out. how do i take the MSB of sum and send it out seperately into a
"cout" output.