engineer21
New Member
Offline
Posts: 1
|
Hello all,
Can somebody help me with Verilog programming. I am using Xilinx to program and modelsim to simulate. The problem I am having is in the module named add_or_subtract. What I am trying to do is compare the check_next_bit with check_bit. Check_bit is being passed in and check_next_bit is assigned a value of 0. These are some of the errrors that I get :"Reference to scalar reg 'check_next_bit' is not a legal net lvalue","Illegal left hand side of continuous assign". I need to assign values to a and s with the if statements then what ever i get from there I will assign them to add and sub. Can somebody help me:
module not working: module add_or_subtract(check_bit,add,sub); input check_bit; output add,sub; reg check_next_bit,bit; reg a,s;
assign check_next_bit= 0; assign bit = 1; assign a=0; assign s=0;
always @(bit) begin
if(check_bit<=check_next_bit) begin a = 1; s = 0; end else if (check_bit>=check_next_bit) begin a = 0; s = 1; end end assign sub=s; assign add=a; endmodule
Entire program `timescale 1ns / 1ps //////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 19:26:12 10/23/05 // Design Name: // Module Name: new_booth // Project Name: // Target Device: // Tool versions: // Description: // // Dependencies: // // Revision: // Revision 0.01 - File Created // Additional Comments: // //////////////////////////////////////////////////////////////////////////////// module new_booth(clk,go,in_bus,out_bus,multiplicand_twos,add,sub);
input [3:0] in_bus; input clk,go; output [3:0]out_bus,multiplicand_twos; reg [3:0] multiplier; reg [3:0] multiplicand; output add,sub; always @ (posedge go) begin assign multiplier = in_bus; //assign a[15:8] = a[7]; end always @(posedge clk) begin assign multiplicand = in_bus; //assign b[15:8] = b[7]; end
twos_comp one(multiplier,multiplicand_twos); add_or_subtract f0(multiplier[0],add,sub); endmodule //////////////////////////////////////////////////////////////////////////////// module twos_comp(m,n); input [3:0] m; output [3:0] n; assign n=(~m) + 4'b0001;
endmodule /////////////////////////////////////////////////////////////////////////////// module add_or_subtract(check_bit,add,sub); input check_bit; output add,sub; reg check_next_bit,bit; reg a,s;
/* assign check_next_bit= 0; assign bit = 1; assign a=0; assign s=0; */
always @(bit) begin
if(check_bit<=check_next_bit) begin a = 1; s = 0; end else if (check_bit>=check_next_bit) begin a = 0; s = 1; end end assign sub=s; assign add=a; endmodule
|