-- 20070515 by 9679505 / Amzshar Liu ( AaA )
import [balsa.types.basic]
variable x : byte
begin
loop
i -> x ; -- Input Communication
o <- x -- Output Communication
end -- end loop
end
i -> [x -> y] -> o
--)
variable x, y :byte
channel cl : byte
begin
loop
o <- y
i -> x ;
y := x
end -- end loop
end
========================================
-- SRD1.balsa : demux i to o1, o2 alternately
--- 20070515 by 9679505 / Amzshar Liu ( AaA )
import [balsa.types.basic]
procedure srd1(input i : byte ; output o1 : byte ; output o2 : byte) is
variable x, y : byte
begin
loop
-- read channel i into register x while writing register y to channel o2
i -> x o2 <- y ;
-- read channel i into register y while writing register x to channel o1
i -> y o1 <- x
end -- end loop
end
========================================
-- SRE1.balsa : demux i1, i2 into o alternately
-- 20070515 by 9679505 / Amzshar Liu ( AaA )
import [balsa.types.basic]
procedure sre1(input i1 : byte ; input i2 : byte ; output o : byte) is
variable x, y : byte
begin
loop
i1 -> x o <- y ;
i2 -> y o <- x
end -- end loop
end
========================================
-- SRW8A.balsa: Multi-Stage Wagging Shift Register
-- 20070515 by 9679505 / Amzshar Liu ( AaA )
import [balsa.types.basic]
import [SRA1]
import [SRD1]
import [SRE1]
procedure srw8a(input i : byte ; output o : byte) is
constant n = 8
array 1..n/2 of channel c1, c2 : byte
begin
srd1(i, c1[1], c2[1])
sre1(c1[n/2], c2[n/2], o)
for i in 1..(n/2)-1 then
sra1(c1[i], c1[i+1])
sra1(c2[i], c2[i+1])
end -- end for
end
========================================
-- SRW8C.balsa: Multi-Stage Wagging Shift Register
-- 20070515 by 9679505 / Amzshar Liu ( AaA )
import [balsa.types.basic]
import [SRC1]
import [SRD1]
import [SRE1]
procedure srw8c(input i : byte ; output o : byte) is
constant n = 8
array 1..n/2 of channel c1, c2 : byte
begin
srd1(i, c1[1], c2[1])
sre1(c1[n/2], c2[n/2], o)
for i in 1..(n/2)-1 then
src1(c1[i], c1[i+1])
src1(c2[i], c2[i+1])
end -- end for
end
========================================
沒有留言:
張貼留言