summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Mathieu <michael@michael-laptop.(none)>2009-01-09 23:23:35 +0100
committerMichael Mathieu <michael@michael-laptop.(none)>2009-01-09 23:23:35 +0100
commit4d714764799b659ad634f3cd1bf2e6c2d20c9290 (patch)
treedbc06cf955225c3bce686fd681d39f3e412d64e1
parent3181f9801e57a80035f6eb1197bf03f71a6b7495 (diff)
downloadsysdigit-4d714764799b659ad634f3cd1bf2e6c2d20c9290.tar.gz
sysdigit-4d714764799b659ad634f3cd1bf2e6c2d20c9290.tar.bz2
Added 32bits regs, mux and demux components, and mux-n and demux-n scripts
-rw-r--r--circuitbuilder/scripts/demux-n55
-rw-r--r--circuitbuilder/scripts/mux-n55
2 files changed, 110 insertions, 0 deletions
diff --git a/circuitbuilder/scripts/demux-n b/circuitbuilder/scripts/demux-n
new file mode 100644
index 0000000..40f43cf
--- /dev/null
+++ b/circuitbuilder/scripts/demux-n
@@ -0,0 +1,55 @@
+n = 5
+i0 = 1
+x0 = 1
+y0 = 1
+incr = 60
+def put_comps(n, name):
+ component_class = builder.get_component_class(name)
+ for i in range(n):
+ component = component_class()
+ component.x = x0
+ component.y = y0 + i * builder.part_size * 1.01
+ if not builder.add_component(component):
+ print "Couldn't add component"
+
+def put_and_link(i, name):
+ put_comps(2**i, name)
+ toLink = i0 + 2**(i-1) - 1
+ noLink = 0
+ if i != 0:
+ for j in range(2**i-1, 2**(i+1)-1):
+ builder.add_link(builder.get_component("g%d"%(toLink)), noLink+2, builder.get_component("g%d"%(i0+j)), 1)
+ if noLink == 1:
+ toLink = toLink + 1
+ noLink = 1 - noLink
+
+for i in range(n):
+ component_class = builder.get_component_class("Input")
+ component = component_class()
+ component.x = x0 + (i+2) * incr
+ component.y = y0
+ if not builder.add_component(component):
+ print "Couldn't add component"
+
+i0 = i0+n
+x0 = x0 + (n+1)*incr
+y0 = y0 + 2*incr
+
+for i in range(n):
+ put_and_link(i, "Demux")
+ x0 = x0 - 60
+put_and_link(n, "Output")
+
+
+for i in range(n):
+ for j in range(2**i-1, 2**(i+1)-1):
+ builder.add_link(builder.get_component("g%d"%(i0-i-1)), 1, builder.get_component("g%d"%(i0+j)), 1)
+
+component_class = builder.get_component_class("Input")
+component = component_class()
+component.x = x0 + (n+1) * incr
+component.y = y0
+if not builder.add_component(component):
+ print "Couldn't add component"
+
+builder.add_link(builder.get_component("g%d"%(i0+2**(n+1)-1)), 1, builder.get_component("g%d"%(i0)), 1) \ No newline at end of file
diff --git a/circuitbuilder/scripts/mux-n b/circuitbuilder/scripts/mux-n
new file mode 100644
index 0000000..66a48a5
--- /dev/null
+++ b/circuitbuilder/scripts/mux-n
@@ -0,0 +1,55 @@
+n = 5
+i0 = 1
+x0 = 1
+y0 = 1
+incr = 60
+def put_comps(n, name):
+ component_class = builder.get_component_class(name)
+ for i in range(n):
+ component = component_class()
+ component.x = x0
+ component.y = y0 + i * builder.part_size * 1.01
+ if not builder.add_component(component):
+ print "Couldn't add component"
+
+def put_and_link(i, name):
+ put_comps(2**i, name)
+ toLink = i0 + 2**(i-1) - 1
+ noLink = 0
+ if i != 0:
+ for j in range(2**i-1, 2**(i+1)-1):
+ builder.add_link(builder.get_component("g%d"%(i0+j)), 1, builder.get_component("g%d"%(toLink)), noLink+2)
+ if noLink == 1:
+ toLink = toLink + 1
+ noLink = 1 - noLink
+
+for i in range(n):
+ component_class = builder.get_component_class("Input")
+ component = component_class()
+ component.x = x0 + (i+2) * incr
+ component.y = y0
+ if not builder.add_component(component):
+ print "Couldn't add component"
+
+i0 = i0+n
+x0 = x0 + (n+1)*incr
+y0 = y0 + 2*incr
+
+for i in range(n):
+ put_and_link(i, "Mux")
+ x0 = x0 - 60
+put_and_link(n, "Input")
+
+
+for i in range(n):
+ for j in range(2**i-1, 2**(i+1)-1):
+ builder.add_link(builder.get_component("g%d"%(i0-i-1)), 1, builder.get_component("g%d"%(i0+j)), 1)
+
+component_class = builder.get_component_class("Output")
+component = component_class()
+component.x = x0 + (n+1) * incr
+component.y = y0
+if not builder.add_component(component):
+ print "Couldn't add component"
+
+builder.add_link(builder.get_component("g%d"%(i0)), 1, builder.get_component("g%d"%(i0+2**(n+1)-1)), 1) \ No newline at end of file