//Template //Copy this template and name it "hw3.v". // Problem 1: // Write down your name and your account here // Your Name : ####### // Your Account: ####### // //Problem 2: //Look at the memory module and answer //The memory unit contains data and operators in ASCII format. // What will be the equation? //Answer : ######## //(hint: something like 1+2 + 3 =) // //Problem 3: //What will be the bit sequence after clock 0 //from memory_read_s module ? //Just answer first 8-bits. //Answer:########### //(hint: 51 = 00110011) //(hint: Does it provide MSB for the first bit? //(so the answer will be either 00110011 or 11001100) module memory(); reg [7:0] mem [7:0]; initial begin mem[0] = 3+48;//51 ascii code for 3 mem[1] = 43; //43 ascii code for + mem[2] = 4+48;//52 ascii code for 4 mem[3] = 43; //43 ascii code for + // ascii code for - is 45 mem[4] = 5+48;//53 ascii code for 5 mem[5] = 61; //61 ascii code for = mem[6] = 61; mem[7] = 61; end endmodule //You don¡¯t have to know this. // This module memory_read_s will read 1bit data from memory. module memory_read_s(v,ck); input ck; output v; reg [7:0] local_v, index; reg [2:0] cnt; memory m(); reg v; initial index = 0; initial cnt = 0; always @(ck) begin local_v = m.mem[index]; // $display("v = index[%d]= %b\n",index,local_v[cnt]); v = local_v[cnt]; // $display("v = %b ",v); cnt = cnt+1; if(cnt == 0) begin index = index +1; // $display("v = \n"); end end endmodule // //Problem 4 Complete the module so it can perform the required functionality. // // module serial_ascii_adder(result,v,ck); input v,ck; output result; reg[7:0] local_data1,local_data2,result,temp_result; // you will save the incoming bit stream into the registers. // or you can declare more regs and save the value on them. reg[2:0] cnt; reg[2:0] operator;//add : 1 //subtract : 2 //no operator received :3 parameter op_add = 1; parameter op_sub = 2; initial operator = 3; initial cnt = 0; always @(ck) #1 begin // Write down your code here // It should contain this code : $display("result = %d\n",result); //And this : $stop; //The code length will be less than 30 lines. //My code length is 20 lines. There will be no penalty for a little bit longer code as long as your program //produces right answer end // endmodule // ////////////////////////////Do not modify this test_all module//////////////////////////////////////////////////// module test_all(); integer i,j; reg ck; wire [3:0] v1; wire vs; wire same; wire [7:0] result; initial ck = 0; initial begin for(i = 1; i<= 50; i = i+ 1) begin #10; ck = ~ck; end end memory_read_s m_r_s(vs,ck); serial_ascii_adder s_a_a(result,vs,ck); initial $monitor($time, " result = %d",result); endmodule