首页 \ 问答 \ 计算结果和多路复用与否(compute results and mux or not)

计算结果和多路复用与否(compute results and mux or not)

在这里使用伪代码。 这些风格是否有利有弊:

假设你有一个可以添加的alu,或者和xor。 是否有更好的代码可以一直计算可能的答案,然后根据操作码选择答案(在这种情况下是一个热门):

alu_add = a + b;
alu_and = a & b;
alu_or  = a | b;
alu_xor = a ^ b;

...

if(opcode[0])      alu_out = alu_add;
else if(opcode[1]) alu_out = alu_and;
else if(opcode[2]) alu_out = alu_or;
else if(opcode[3]) alu_out = alu_xor;

另一种方法是像这样编码它:

if(opcode[0])      alu_out = a + b;
else if(opcode[1]) alu_out = a & b;
else if(opcode[2]) alu_out = a | b;
else if(opcode[3]) alu_out = a ^ b;

我也看到它:

alu_add = a + b;
alu_and = a & b;
alu_or  = a | b;
alu_xor = a ^ b;

...

alu_out = 
  ( 8{opcode[0]} & alu_add ) |
  ( 8{opcode[1]} & alu_and ) | 
  ( 8{opcode[2]} & alu_or ) |
  ( 8{opcode[3]} & alu_xor );

这两种方法都有利弊,或者它们最终会出现同样的问题吗?


Using pseudo code here. Are there pros and cons to these styles:

Say you have an alu that can do add, and, or and xor. Is it better to have code that computes the possible answers all the time then select the answer based on the opcode (in this case a one hot):

alu_add = a + b;
alu_and = a & b;
alu_or  = a | b;
alu_xor = a ^ b;

...

if(opcode[0])      alu_out = alu_add;
else if(opcode[1]) alu_out = alu_and;
else if(opcode[2]) alu_out = alu_or;
else if(opcode[3]) alu_out = alu_xor;

An alternative would be to code it like this:

if(opcode[0])      alu_out = a + b;
else if(opcode[1]) alu_out = a & b;
else if(opcode[2]) alu_out = a | b;
else if(opcode[3]) alu_out = a ^ b;

I have also seen it as:

alu_add = a + b;
alu_and = a & b;
alu_or  = a | b;
alu_xor = a ^ b;

...

alu_out = 
  ( 8{opcode[0]} & alu_add ) |
  ( 8{opcode[1]} & alu_and ) | 
  ( 8{opcode[2]} & alu_or ) |
  ( 8{opcode[3]} & alu_xor );

Are there pros and cons to either method or do they come out about the same in the end?


原文:https://stackoverflow.com/questions/1395308
更新时间:2023-09-02 08:09

最满意答案

要导入,您可以scp本地m / c中的文件夹

  scp -r -i path-to-secret-key ubuntu@ec2-address:/home/ubuntu/app-folder-location /home/user/local-mc-location

To import, you can scp the folder in your local m/c

  scp -r -i path-to-secret-key ubuntu@ec2-address:/home/ubuntu/app-folder-location /home/user/local-mc-location

相关问答

更多
  • 我认为它们带有专有的插件,你无法通过Eclipse的库存安装获得。 与Zend IDE相同。 您可以使用Eclipse获得大部分相同的功能,但是您必须自己安装它并且不会得到任何支持。 I think they come with proprietary plugins that you can't necessarily get with a stock install of Eclipse. Same with the Zend IDE. You can get most of the same func ...
  • 您只需要使用现有的项目文件夹在Aptana Studio中创建一个新项目。 假设你有一个驻留在project_folder的项目。 如果您不确定任何事情,请先备份您的项目。 转到File -> New -> Choose the type of project you wan 在弹出的窗口询问详细信息时,将Location指向现有项目,在这种情况下为/some_path/project_folder 创建一个新项目会在你的项目文件夹中生成一个.project文件,所以你可能想把它放到.gitignore这样 ...
  • 要导入,您可以scp本地m / c中的文件夹 scp -r -i path-to-secret-key ubuntu@ec2-address:/home/ubuntu/app-folder-location /home/user/local-mc-location To import, you can scp the folder in your local m/c scp -r -i path-to-secret-key ubuntu@ec2-address:/home/ubuntu/app-f ...
  • 不幸的是PDT没有这样的功能。 您可以: 通过命令行或eclipse外部程序配置使用rsync 将aptana与pdt一起使用 Unfortunately PDT haven't such feature. You can: Use rsync via command line or eclipse external program configuration Use aptana together with pdt
  • 试试乌龟git,你将拥有与乌龟svn相同的整合。 你不能将PHPEd的调试器与Aptana一起使用,我已经使用了Xdebug和PHPEd的调试器,我可以告诉你,与PHPEd相比,Xdebug是垃圾。 我不适用于NuSphere,但他们拥有绝对最好的PHP调试器。 Try tortoise git, you will have the same kind of integration like you had with tortoise svn. And you cannot use PHPEd's debu ...
  • 我相信这可以通过参考StackOverflow关于克隆特定文件夹的现有问题来帮助,我正在寻找与Aptana类似的东西并找到两者,希望这有帮助。 此答案最初由CanBerkGüder提供,以回应以下引用的问题。 选项A: git clone git@github.com:whatever folder-name 选项B: 也移动.git文件夹。 更好的是: 将您的工作副本保存在其他位置,并创建符号链接。 参考: 如何将Git存储库克隆到特定文件夹中? I believe this can be helped ...
  • http://pydev.org/manual_101_root.html中的第一行说: “本手册假设您已经在您的机器中安装了Python和/或Jython和/或IronPython,以及Eclipse,Aptana Studio 2或Aptana Studio 3。” 所以它应该适用于Aptana 3 :-) 你确定你根据你的python版本从Tkinter导入/从tkinter导入使用正确的吗? 另外,你检查过libs是否正确加载到Aptana? / lib /和/ Lib /可能会导致问题。 (不确定 ...
  • 此响应假设您使用的是Aptana Studio 3(或其移动版本的Titanium Studio)。 我不确定你使用的Aptana版本是基于原始文章的。 Aptana使用WEBrick作为默认的Rails服务器。 要启动服务器,首先从App Explorer视图的列表/下拉列表中选择您的项目(如果此视图不可见,请使用Window - > Show View - > App Explorer来显示它)。 现在项目在您的App Explorer中处于活动状态,单击Commands图标(看起来像蓝色链轮),也是A ...
  • 有一些关于在本地项目和FTP站点之间建立连接的Wiki页面: https://wiki.appcelerator.org/display/tis/FTP%2C+SFTP%2C+and+FTPS+Deployment https://wiki.appcelerator.org/display/tis/Create+a+FTP+Connection https://wiki.appcelerator.org/display/tis/Managing+FTP+Connections 希望这些帮助。 There a ...
  • 可能你的PYTHONPATH没有在Eclipse / PyDev中正确设置......或者设置模块可能不正确(右键单击项目> properties> pydev - django:应该在那里正确设置django设置模块)。 如果您仍然无法找到它,请发布带有项目配置的pydev软件包资源管理器的屏幕截图,并发布manage.py文件的内容。 Probably your PYTHONPATH is not properly set inside Eclipse/PyDev... Or maybe the set ...

相关文章

更多

最新问答

更多
  • 获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
  • 如何通过引用返回对象?(How is returning an object by reference possible?)
  • 矩阵如何存储在内存中?(How are matrices stored in memory?)
  • 每个请求的Java新会话?(Java New Session For Each Request?)
  • css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
  • 无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
  • xcode语法颜色编码解释?(xcode syntax color coding explained?)
  • 在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
  • 从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
  • 从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
  • 西安哪有PLC可控制编程的培训
  • 在Entity Framework中选择基类(Select base class in Entity Framework)
  • 在Android中出现错误“数据集和渲染器应该不为null,并且应该具有相同数量的系列”(Error “Dataset and renderer should be not null and should have the same number of series” in Android)
  • 电脑二级VF有什么用
  • Datamapper Ruby如何添加Hook方法(Datamapper Ruby How to add Hook Method)
  • 金华英语角.
  • 手机软件如何制作
  • 用于Android webview中图像保存的上下文菜单(Context Menu for Image Saving in an Android webview)
  • 注意:未定义的偏移量:PHP(Notice: Undefined offset: PHP)
  • 如何读R中的大数据集[复制](How to read large dataset in R [duplicate])
  • Unity 5 Heighmap与地形宽度/地形长度的分辨率关系?(Unity 5 Heighmap Resolution relationship to terrain width / terrain length?)
  • 如何通知PipedOutputStream线程写入最后一个字节的PipedInputStream线程?(How to notify PipedInputStream thread that PipedOutputStream thread has written last byte?)
  • python的访问器方法有哪些
  • DeviceNetworkInformation:哪个是哪个?(DeviceNetworkInformation: Which is which?)
  • 在Ruby中对组合进行排序(Sorting a combination in Ruby)
  • 网站开发的流程?
  • 使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)
  • 条带格式类型格式模式编号无法正常工作(Stripes format type format pattern number not working properly)
  • 透明度错误IE11(Transparency bug IE11)
  • linux的基本操作命令。。。