How to Maintain Output Values in Verilog Like Registers?

  • Thread starter Thread starter KingNothing
  • Start date Start date
AI Thread Summary
To maintain output values in Verilog like registers, the user is attempting to assign output values to a register, specifically using the `CItemp` register to hold values. The challenge arises from needing to respond to positive edges from multiple inputs while determining which input triggered the change. The user has identified that the procedural block for detecting positive edges does not allow for differentiation between the inputs that caused the edge. A solution involves using conditional statements within the edge-triggered block to check each input's state and assign the corresponding output. This approach will enable the correct output assignment based on the specific input that generated the positive edge.
KingNothing
Messages
880
Reaction score
4
Hi. I'm new to verilog and I'm trying to do something that to me, seems very simple. I have a file with some logic and outputs, and all I want is for the outputs to hold their values, like registers.

In other words, if output = 001, I want it to stay that way until it is re-assigned. The problem I am having, is that verilog won't let me assign my output or a wire to a register value.

Here is my code so far:
Code:
module coin_input(CI, button_out_signal, button_in);
	output [1:0] CI;
	output button_out_signal;
	input [3:0] button_in;
	
	wire [2:0] button_id;
	
	reg [1:0] CItemp;
	wire [1:0] CItemp2;
	assign CI[1] = CItemp2[1];
	assign CI[0] = CItemp2[0];
	assign CItemp2[1] = CItemp[1];
	assign CItemp2[0] = CItemp[0];
	
	
	//Connect buttons to button stabilizers
	//Button_Stabilizer(button_out, button1_in, enter)
	Button_Stabilizer	bs2(button_id[2], button_in[3], button_in[0]),
						bs1(button_id[1], button_in[2], button_in[0]),
						bs0(button_id[0], button_in[1], button_in[0]);
						
	//Convert button_id's to CI to give precedence to higher-value coins
	always @(posedge button_in[3]) begin
		{CItemp[1], CItemp[0]} <= 2'b11;
	end
	
	always @(posedge button_in[2]) begin
		{CItemp[1], CItemp[0]} <= 2'b10;
	end
	
	always @(posedge button_in[1]) begin
		{CItemp[1], CItemp[0]} <= 2'b01;
	end

	//Set button_out_signal to 1
	assign button_out_signal = button_in | 1'b0;
endmodule

You can see that I am using the register CItemp to hold the values that I want to store. I want to assign the output, CI, to this register value. How in the world do I do that?
 
Engineering news on Phys.org
I'm really very sorry, but I believe I have figured out what I was doing wrong above. I've traced it back to a different issue, actually.

The problem is that I have a circuit with three different inputs, and the circuit is supposed to react based on a positive edge from any of the inputs. For example, if input1 has a positive edge, the output should be set to 01. If input2 has a positive edge, the output should be set to 10.

I am having a serious issue coding this. I have one procedural statement to excute a bunch of code when there is a positive edge in either input:
Code:
always @(posedge button_id[2] or posedge button_id[1] or posedge button_id[0]) begin

But, I am not able to write good logic after that, because once inside that procedural statement, how can the code be aware of WHICH input generated a positive edge?
 
Hi all I have some confusion about piezoelectrical sensors combination. If i have three acoustic piezoelectrical sensors (with same receive sensitivity in dB ref V/1uPa) placed at specific distance, these sensors receive acoustic signal from a sound source placed at far field distance (Plane Wave) and from broadside. I receive output of these sensors through individual preamplifiers, add them through hardware like summer circuit adder or in software after digitization and in this way got an...
I have recently moved into a new (rather ancient) house and had a few trips of my Residual Current breaker. I dug out my old Socket tester which tell me the three pins are correct. But then the Red warning light tells me my socket(s) fail the loop test. I never had this before but my last house had an overhead supply with no Earth from the company. The tester said "get this checked" and the man said the (high but not ridiculous) earth resistance was acceptable. I stuck a new copper earth...
I am not an electrical engineering student, but a lowly apprentice electrician. I learn both on the job and also take classes for my apprenticeship. I recently wired my first transformer and I understand that the neutral and ground are bonded together in the transformer or in the service. What I don't understand is, if the neutral is a current carrying conductor, which is then bonded to the ground conductor, why does current only flow back to its source and not on the ground path...

Similar threads

Replies
1
Views
1K
Replies
1
Views
3K
Replies
1
Views
8K
Replies
1
Views
3K
Replies
1
Views
21K
Back
Top