Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6747697
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T12:28:29+00:00 2026-05-26T12:28:29+00:00

At my work we utilize processors with boolean logic programs for an industrial application.

  • 0

At my work we utilize processors with boolean logic programs for an industrial application. These programs can get very long and complex. They basically consist of sets of input bits, output bits, and internal boolean bits. These bits are then used in logic statements that result in the outputs. The inputs and outputs can be either physical wire outputs or serial communication, but that’s not really important.

Here’s a quick, simplified example:

Inputs:
input1, input2, input3;

Outputs:
output1, output2, output3;

Boolean:
bool1, bool2, bool3;

Logic:
assign input1 && input2 to bool1;
assign input1 && bool1 to output1;
assign input2 && input3 to bool2;
assign output1 && bool2 to output2;
assign output1 && output2 || bool2 to bool3;

So, keep in mind that I’m very new to Java. I’ve done quite a bit of web based programming (ruby, php, javascript, etc).

Basically what I’d like the simulator to do is break down the formatting of the program and allow for graphically simulation. The programs can communicate to each other, and thus the simulator should be able to handle multiple programs as well (and tie the I/O together).

My problem is getting started with organization. I’d assume that I need to have a “bit” class. This class would store whether the bit is set to TRUE or FALSE, the type of bit, the relevant equation, what processor the bit is from, etc.

But then, I can get to the point where I have hundreds, or thousands of “bit” instances. How I can organize these bits then? If I wanted to grab all instances that are from, for example, a certain processor, how could I accomplish that?

Also, when I change the status (TRUE or FALSE) of an input bit within the simulator, it will then update the status of several other bits. Any suggestions on this? I’d like to make this as flexible as possible because i’d like to add additional functionality. For example, certain bits can be designated as timers (it can take a certain amount of time for them to set when their conditions are met, or it can take a certain amount of time for them to drop away when their conditions are no longer met).

My initial thought was to keep arrays or hashes of the objects and attempt to keep them organized somehow in that way.

I’m basically looking for any suggestions. Thanks in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T12:28:30+00:00Added an answer on May 26, 2026 at 12:28 pm

    Interesting problem. You are basically building a simple virtual processor of boolean values. So I would build the simulator as more of a processor. So essentially you’ll have registers (input, output, or internal registers), then the logic would define your operands. Since you are only dealing with boolean logic it’s pretty easy to come up with a set of operands that you need: AND, OR, NOT, XOR. For things like &&, || those operands will have two inputs and one output. But, for NOT you’ll have only one input and one output. So I’d create a Class for each operand you want to support. And either an abstract Class or interface all operands extend/implement. That will provide the interface for the client to evaluate each operand in the same manner and execute the program.

    For example:

    public class AndOperation implements Operand, Argument {
    
        private Argument argument1;
        private Argument argument2;
        private String output;
    
        public AndOperation( Argument arg1, Argument arg2 ) {
           this( arg1, arg2, null ); // this is for chaining where no output exists.
        }
    
        public AndOperation( Argument arg1, Argument arg2, String output ) {
           this.argument1 = arg1;
           this.argument2 = arg2;
           this.output = output;
        }
    
        public boolean evaluate() {
           return argument1.evaluate() && argument2.evaluate();
        }
    
        public String getOutputRegister() {
           return output;
        }
    }
    
    public interface Argument {
        public boolean evaluate();
    }
    
    public class Register implements Argument {
        private String name;
        private boolean value;
    
        public boolean evaluate() {
           return value;
        }
    
        public void setValue( boolean value ) {
           this.value = value;
        }
    }
    
    
    public class Program implements Iterable<Operand> {
    
       public Map<Register> registers;
       public List<Operand> operands;
    
       public void parse( InputStream stream ) {
          // this will take in a stream, parse it, and create the 
          // program.  Create the registers, and operands used 
          // to evaluate the program
       }
    
       public void evaluate() {
          for( Operand op : operands ) {
             evaluate( op );
          }
       }
    
       public void evaluate( Operand operand ) {
             boolean output = op.evaluate();
             String name = op.getOutputRegister();
             Register register = registers.get( name );
             register.setValue( output );
       }          
    
       public Iterator<Operand> iterator() {
          return new Debugger( this );
       }
    }
    
    public class Debugger implements Iterator<Operand> {
       private Program program;
       private int line = 0;
    
       public boolean hasNext() {
          return line < program.size();
       }
    
       public Operand next() {
          Operand operand = program.getOperands().get( line );
          program.evaluate( operand );
          line++;
          return operand;
       }
    }
    

    That’s roughly it. However, one thing I wanted to point out was how chaining multiple operands together can be transparently done. The operand doesn’t care if it’s reading its input from a register or another operand. Since the Register and Operand implements Argument then it substituted for either. So for example:

    Operand op = new AndOperand( register1, new OrOperand( register2, register3 );
    boolean output = op.evaluate(); // this is register1 && (register2 || register3 )
    

    Of course the tricky part is going to be parsing it, but that’s a little difficult to show in this limited space. As far as graphically representing this you could build something that took this program and evaluated it operand by operand and rendered it to the screen in some way. It’s possible to build a debugger off of this without much more effort. Just need a little more information that your parser could create (line number to operand map would be helpful).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Work on asp.net vs05. I have three type of value Like:IsDesign,IsPrinting,IsInstall they are bit
Work on this small test application to learn threading/locking. I have the following code,
Whenever I talk to people that work with real-time preformance they tend to point
I am using an application required by this project that must utilize regular expression
Using SpiderMonkey you can utilize conditional catch blocks to route exceptions to the appropriate
I'm wondering how these work under the hood, especially for large result sets. For
I'd like to work on a 2-3 month long project (full time) that involves
I'm not quite sure I'm understanding how I can utilize generics in C# properly.
work on asp.net vs 05 C#.Master page header contain the bellow code <script type=text/javascript
work on SQL Server 2000. want to Automated Email Notifications using SQL Server Job

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.