Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to create a custom logic device in Circuitjs

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/02 Report--

This article shows you how to create a custom logic device in Circuitjs, which is concise and easy to understand, which will definitely brighten your eyes. I hope you can get something through the detailed introduction of this article.

A concrete example

Let's look at a concrete example of what custom logic is, why and how to do it.

This example is as follows, two inputs A1 and A0, two outputs S1 and S0, the relationship between the two is also very simple, that is, the input is simply reversed, so two non-gates are used to achieve the goal.

The relationship between output and input is:

S1s, A1S0s, A0.

One of the exclamation points! It means to take the opposite.

The above logic is directly implemented by the circuit, and now suppose we want to use custom logic to do an equivalent implementation, so as to replace the circuit composed of the above non-gate, how to do it?

As to why custom logic is introduced, it will be explained later.

The first step is to add a custom logic device, select add Custom Logic from the menu or right button, and then drag to generate a default custom logic device:

By default, it contains two inputs An and B, and two outputs C and D, but this is only the default and can be further adjusted. Both inputs and outputs can be one or more, not limited to two.

The next step is to double-click (or "right-edit") the component to edit its properties:

First give it a name, such as "two-bit-invert":

Then click to edit the model, in the pop-up window, there are four attributes that can be edited, namely input, output, information text, definition, which will be described below:

Input

Change it to A 1 Magi A 0, consistent with the prototype, separated by commas. Of course, what is actually called here is not particularly important, you can define it according to your own needs, but it is recommended to be as brief as possible.

Depending on the situation, the input can have more or less. For example, Xmeny Y Z means that there are three inputs, and the names are set to Xpene Y and Z.

Output

Change it to S1Magol S0, which is consistent with the prototype (in the same way, it doesn't really matter what it's actually called here)

Similarly, the output is not limited to two, can be more or less.

Information text

Here you can fill in a specific description of the function, such as "reverse each bit of input".

Define

This is the most important, it defines the logical relationship between input and output.

How do you define it? The easiest way is to enumerate the combinations of all inputs and give the corresponding output values.

If you have a digital circuit foundation, it's obviously the same thing as the so-called truth table (True Table).

Then the final definition of the aforementioned anti-logic is as follows:

0011011010101110000

The final result is as follows:

The equal sign corresponds to input on the left and output on the right.

In the first line, 00 on the left represents A1N1 and A000respectively, and 11 on the right represents S1N1 and S01respectively.

In the second line, 01 on the left represents A1, A0, respectively, and 10 on the right indicates S1, S0, respectively.

In the third line, 10 on the left represents A1, A0, respectively, and 01 on the right indicates S1, S0, respectively.

In the fourth line, 11 on the left represents A1, A0, respectively, and 00 on the right represents S1, S0, 0, respectively.

Obviously, the above expresses the aforementioned inversion logic by enumerating all inputs (and corresponding outputs):

S1s, A1S0s, A0.

If you create another custom logic with the following definition:

000011101111,

Then a logical component with two inputs and one output is defined.

Obviously, the above definition is actually an OR door.

Similarly, you can define more complex XOR gates, semi-adders, full adders, decoders, and other logic components you want.

After confirmation, the input and output name of the component is displayed as follows. When the mouse is moved up, the corresponding name and information text will be displayed in the lower right corner of the canvas:

Next, you can test whether it satisfies the corresponding logic, and if not, you may need to carefully check whether the rules in the definition are incorrect; if all OK, you can use it to replace the circuit composed of two non-gates.

Naturally, custom logic has no advantage for simple, easy-to-implement logic.

But for more complex, more input, output cases, you may not think of how to use the circuit to achieve, or can be implemented in the circuit, but it is very complex, a variety of components, a lot of connections, then the custom logic has an advantage.

In the end, all the logic still has to fall on the specific circuit implementation, custom logic is sometimes more like an "opportunistic", but used well, it can still help you in the overall design period, first ignore the specific implementation of some modules, so as not to get lost in too many details, you can assume that these sub-components have been implemented, and then test whether the overall logic is OK.

When there is no problem with the large framework and interaction, you can go back and implement the custom logic one by one, so it can also help you postpone some implementation without affecting the overall functionality.

Summary

Each custom logic device has a model name that points to the model that describes how it works.

You can create any number of devices of the same model.

Editing the model changes the behavior of all devices that use the model.

When editing a model, you can specify input, output, some information text (displayed in the lower right corner when hovering over the device), and definitions.

The input (and output) is a comma-separated list of short pin tags (up to one or two characters).

You can also specify an inverse label, such as / Q corresponds to Q.

Example: a _

The definition is the input = output in the form of multiple lines.

The first input mode that matches the input pin is selected and the output pin is set to match the output mode.

Patterns can contain bit values (0,1), transitions (+, -), wildcards / arbitrary values (?), and pattern letters (A, B, etc.).

The input must not be less than the number of input pins.

If longer, additional mode characters are matched to the output pins; this allows you to create devices with states.

The output mode can also include _ to indicate the high impedance state.

More exampl

The concrete examples above represent the most basic and most commonly used cases, but custom logic also supports more complex expressions, such as wildcards, and even, in addition to combinational logic, you can define sequential logic components.

Here are some specific examples and instructions.

3 input and not gate

Input: a _

Output: X

Definition:

1111 / 0 / 01 / 11 / 01 / 11 / 01 / 11 / 01 / 11 / 01 / 11 / 01 / 11 / 01 / 11 / 01 / 01 / 11 / 01 / 01 / 01 / 11 / 01 / 01 / 01 / 01 / 01 / 01 / 01 / 01 / 01 / 01 / 01 / 01 / 01 / 01 / 01 / 01 / 01 / 01 / 01 / 01 / 01 / 01 / 11 / 01 / 01 / 01 / 01 / 01 / 01 / 01 / 01 / 11 / 01 / 01 / 01 / 01 / 01 / 11 / 01 / 11 / 01 / 11 / 01 / 01 / 11 / 01 / 11 / 01 / 11 / 01 / 11 / 01 / 11 / 01 / 11 / 01 / 11 / 01 / 11 / 01 / 11 / 01 / 01 / 11 / 01 / 01 / 11 / 01 / 01 / 11 / 01 / 11 / 01 / 11 / 01 / 11 / 01

If all three inputs are 1, the output is 0. 0. Otherwise, it is 1.

Full adder

Input: a _

Output: ScriptC

Definition:

111=11110=10011=10101=10100=01010=01001=01000=00SR latch

Input: Sforme R

Output: QJI PUQ

Definition:

? AB=AB

The input pattern (to the left of the equal sign) matches S, R, Q and Q.

The corresponding Q and Q result values are specified to the right of the equal sign.

In the first line, if both inputs are low, set the Q output (this setting is required for resetting the circuit).

In the second line, if the set is high, the output is set to 1. 0.

In the third line, if the reset end (reset) is high, the output is set to 0. 0.

The fourth line, except for the above, will leave the output unchanged.

The first two letters match the input pin and the last two letters match the output pin.

Spaces will be ignored, adding spaces here is only for clarity.

D flip-flop

Input: d _ MagneClk

Output: QJI PUQ

Definition:

?? 00? 100 +? = 011 +? = 10? AB=AB

If both inputs are low, the first line sets the Q output (this setting is required when resetting the circuit).

The next two lines set the Q output to match the D input at the rising edge of the clock.

Except in the above cases, the output of the last exercise remains unchanged.

JK trigger

Input: JJJ KJEI Clk

Output: QJI PUQ

Definition:

?? 0000000-AB=AB10-? = 1001 -? = 0111-AB=BA??? AB=AB

If both inputs are low, the first line sets the Q output (this setting is required when resetting the circuit).

The next four lines implement JK trigger logic on the negative jump of the clock.

Except in the above cases, the output of the last exercise remains unchanged.

Digital comparator

Input: a _ 2 ~ ~ A _ 1 ~ A _ 0 ~ B _ 2 ~ ~ B _ 1 ~ B0

Output: Eq,A >, A

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report