130 Synchronous communication creation module rom8*8(y,in); output [7:0] y; input [2:0] in; reg [2:0] ROM [7:0]; assign y=rom[in]; initial $readme mb( rom_data.txt,rom,0,7); module module fs32_test(); reg [2:0] testvectors[8:0]; reg clk; reg [10:0]N,err; reg a,b,c; fs d_t,e_t; fs32 DUT(a,b,c,d_t,e_t); initial begin $readmemb( testvectors_fs32.txt,testvectors); N=0;err=0; always begin clk=0; #50; clk=1; #50; APPENDIX-I always @(posedge clk)begin a=testvectors[n][0]; b=testvectors[n][1]; c=testvectors[n][2]; always @(nedge clk)begin N=N+1; $display( inputs %b%b%b-output %b%b,a,b,c,d_t,e_t); always @(N)begin if(n==100 testvectors[n}===3 bx)begin $display( Completed %d tests with %d errors,n,err); $finish; module module fs32(x,y,bin,diff,bout); input x; input y; input bin; output diff; output bout; assign diff=x^y^bin;
131 assign bout=(y&bin) ((y bin)&(~x)); module 2. RA One s and Two s complement module module complement s (d, clk, q); input d; input clk; output q; flip [N-1:0] q1; dff dff1(d,clk,q1[0]); dff dff1(q1[0],clk,q1[1]); dff dff1(q1[1],clk,q1[2]); dff dff1(q1[n-1],clk,q); dff dff1(q1[n],clk q) module module dff(d,clk,q); input d; input clk; output q; reg q; always @(posedge clk) q=d; module (i) Adder and subtractor module fa(a,b,cin,sum,cout); input [N:0]a; input [N:0]b; input cin; output [N:0] sum; output cout; fa[n-1:0] c1; fa fa1(a[0],b[0],cin, sum[0],c1[0]); fa fa2(a[1],b[1],c1[0], sum[1],c1[1]); fa fa(a[n-1],b[n-1],c1[1], sum[n-1],c1[n-1]); fa fa4(a[n],b[n],c1[n-1], sum[n],cout); module module fa (a,b,cin,sum,cout); input a; input b; input cin; output sum; output cout; fa s1,c1,c2; xor xor1(s1,a,b); xor xor2(sum,s1,cin); and and1(c1,a,b); and and2(c2,s1,cin); or or1(cout,c1,c2); module
132 Resolving host in self-healing hardware APPENDIX-II namespace NetPinger public partial class IPScanForm : Form private IPScanner _scanner; private class HostSorterByIP : IComparer public int Compare(object x, object y) byte[ ] bytes1 =(IPScanHostState)((ListViewItem)x).Tag).Address.GetAddressBytes(); byte[ ] bytes2 = ((IPScanHostState)((ListViewItem)y).Tag).Address.GetAddressBytes(); int i = bytes1.length - 1; for (; i > 0 && bytes1[i] == bytes2[i]; i--); return bytes1[i] - bytes2[i]; }} public IPScanForm() InitializeComponent(); _scanner = new IPScanner((int)_spnConcurrentPings.Value, (int)_spnpingsperscan.value, _cbcontinuousscan.checked, (int)_spntimeout.value, (int)_spnttl.value, _cbdontfragment.checked, (int)_spnbuffersize.value); _scanner.onalivehostfound += new IPScanner.AliveHostFoundDelegate(_scanner_OnAliveHostFound); _scanner.onstartscan += new IPScanner.ScanStateChangeDelegate(_scanner_OnStartScan); _scanner.onstopscan += new IPScanner.ScanStateChangeDelegate(_scanner_OnStopScan); _scanner.onrestartscan += new IPScanner.ScanStateChangeDelegate(_scanner_OnRestartScan); _scanner.onscanprogressupdate += new IPScanner.ScanProgressUpdateDelegate(_scanner_OnScanProgressUpdate); _lvalivehosts.listviewitemsorter = new HostSorterByIP(); _cmbrangetype.selectedindex = 0; } private void _scanner_onalivehostfound(ipscanner scanner, IPScanHostState host) if (InvokeRequired) BeginInvoke(new IPScanner.AliveHostFoundDelegate(_scanner_OnAliveHostFound), scanner, host); return; } ListViewItem item = new ListViewItem(); item.tag = host; item.backcolor = Color.GreenYellow; item.subitems.add(host.address.tostring()); item.subitems.add(""); item.subitems.add(""); item.subitems.add(""); _lvalivehosts.items.add(item); _lvalivehosts.sort(); host.onhostnameavailable += new IPScanHostState.HostNameAvailableDelegate(host_OnHostNameAvailable); host.onstatechange += new IPScanHostState.StateChangeDelegate(host_OnStateChange); if (!host.istesting())
133 item.imageindex = (int)host.qualitycategory; item.subitems[2].text = host.avgresponsetime.tostring("f02") + " ms"; item.subitems[3].text = ((float)(host.losscount) / host.pingscount).tostring("p"); item.subitems[4].text = host.hostname; } 2. Power analysis of self-healing hardware with IP Scanner #region IPScanRange Public class IPScanRange #region Start Private IPAddress_start; Public IPAddress Start get return_start;}} public IPScanner(int concurrentpings, int pingsperscan, bool continuousscan); public IPScanner(int concurrentpings, int pingsperscan, bool continuousscan, int timeout); public IPScanner(int concurrentpings, int pingsperscan, bool continuousscan, int timeout, int ttl, bool dontfragment, int pingbuffersize); IPScanRange(IPAddress start, IPAddress ); IPScanRange(IPAddress start, int subnet); #region
134 Appix-III Data synchronizing function of master module Double_5 S y = zeros(1,5); y(1) = 112; y(2) = 111.9991999; y(3) = 154524; y(4) = 11147.9991999; y(5) = 11241521.123455789; uint16 S y=uint16(1120); uint8_2 S y = uint8(zeros(1,2)); y(1) = uint8(hex2dec('aa')); y(2) = uint8(hex2dec('ff')); uint16_9 s y = uint16(zeros(1,9)); y(1) = uint16(hex2dec('aaff')); y(2) = uint16(hex2dec('ff00')); y(3) = uint16(hex2dec('55f0')); y(4) = uint16(hex2dec('aaaa')); y(5) = uint16(hex2dec('ffff')); y(6) = uint16(hex2dec('f520')); y(7) = uint16(hex2dec('aabc')); y(8) = uint16(hex2dec('ffed')); y(9) = uint16(hex2dec('f052')); uint32_10 S y = uint32(zeros(1,10)); y(1) = uint32(hex2dec('ee33aaff')); y(2) = uint32(hex2dec('ff001423')); y(3) = uint32(hex2dec('f0d5a400')); y(4) = uint32(hex2dec('aaaa1111')); y(5) = uint32(hex2dec('ffffbbbb'));
135 y(6) = uint32(hex2dec('f520aaaa')); y(7) = uint32(hex2dec('aabe4a6c')); y(8) = uint32(hex2dec('ffed2563')); y(9) = uint32(hex2dec('f052aaaa')); y(10) = uint32(1234567890); double_2 S y=zeros(1,2); y(1)=1; y(2)=1; double_2 Receive function [x, y] = fcn(u) x = u(2); y = u(1); double_5 Receive y = uint8(abs(u(1) - 112) < 1e-6 && abs(u(2) - 111.9991999) < 1e-6 &&... abs(u(3) - 154524) < 1e-6 && abs(u(4) - 11147.9991999) < 1e-6 &&... abs(u(5) - 11241521.123455789) < 1e-6); u(1) = 0; u(2) = 0; u(3) = 0; u(4) = 0; u(5) = 0; unit16 Receive y = uint8(uint16(1120)== u); u = uint16(0); Uint8_2 Receive y = uint8(uint8(hex2dec('aa')) == u(1) && uint8(hex2dec('ff')) == u(2)); Uint16_9 Receive
136 y = uint8(u(1) == uint16(hex2dec('aaff')) && u(2) == uint16(hex2dec('ff00')) &&... u(3) == uint16(hex2dec('55f0')) && u(4) == uint16(hex2dec('aaaa')) &&... u(5) == uint16(hex2dec('ffff')) && u(6) == uint16(hex2dec('f520')) &&... u(7) == uint16(hex2dec('aabc')) && u(8) == uint16(hex2dec('ffed')) &&... u(9) == uint16(hex2dec('f052'))); u(3)=0; u(4)=0; u(5)=0; u(6)=0; u(7)=0; u(8)=0; u(9)=0; uint32_10 Receive y = uint8(u(1) == uint32(hex2dec('ee33aaff')) && u(2) == uint32(hex2dec('ff001423')) &&... u(3) == uint32(hex2dec('f0d5a400')) && u(4) == uint32(hex2dec('aaaa1111')) &&... u(5) == uint32(hex2dec('ffffbbbb')) && u(6) == uint32(hex2dec('f520aaaa')) &&... u(7) == uint32(hex2dec('aabe4a6c')) && u(8) == uint32(hex2dec('ffed2563')) &&... u(9) == uint32(hex2dec('f052aaaa')) && u(10) == uint32(1234567890)); u(3)=0; u(4)=0; u(5)=0; u(6)=0; u(7)=0; u(8)=0; u(9)=0; u(10)=0; AND function y = fcn(t,u,v,w,z) if(uint8(t) && uint8(z) && uint8(u) && uint8(v) && uint8(w)) y=uint8(1); else y=uint8(0);
137 Appix-IV Data synchronizing function of slave module Double_5 S y = double(zeros(1,5)); y(1) = double(112); y(2)= double(111.9991999); y(3) = double(154524); y(4)= double(11147.9991999); y(5) = double(11241521.123455789); uint16 S y=uint16(1120); uint8_2 S y = uint8(zeros(1,2)); y(1) = uint8(hex2dec('aa')); y(2) = uint8(hex2dec('ff')); uint16_9 S y = uint16(zeros(1,9)); y(1) = uint16(hex2dec('aaff')); y(2) = uint16(hex2dec('ff00')); y(3) = uint16(hex2dec('55f0')); y(4) = uint16(hex2dec('aaaa')); y(5) = uint16(hex2dec('ffff')); y(6) = uint16(hex2dec('f520')); y(7) = uint16(hex2dec('aabc')); y(8) = uint16(hex2dec('ffed')); y(9) = uint16(hex2dec('f052')); uint32_10 y = uint32(zeros(1,10)); y(1) = uint32(hex2dec('ee33aaff')); y(2) = uint32(hex2dec('ff001423')); y(3) = uint32(hex2dec('f0d5a400')); y(4) = uint32(hex2dec('aaaa1111')); y(5) = uint32(hex2dec('ffffbbbb')); y(6) = uint32(hex2dec('f520aaaa')); y(7) = uint32(hex2dec('aabe4a6c'));
138 y(8) = uint32(hex2dec('ffed2563')); y(9) = uint32(hex2dec('f052aaaa')); y(10) = uint32(1234567890); double_2 S function y = fcn(u,v ) y = zeros(1,2); y(1) = u; y(2) = v; double_5 Receive y = uint8(abs(u(1) - double(112)) < 1e-6 && abs(u(2) - double(111.9991999)) < 1e-6 &&... abs(u(3) - double(154524)) < 1e-6 && abs(u(4) - double(11147.9991999)) < 1e-6 &&... abs(u(5) - double(11241521.123455789)) < 1e-6); u(3)=0; u(4)=0; u(5)=0; uint16 Receive y = uint8(uint16(1120)== u); u = uint16(0); uint8_3 Receive y = uint8(uint8(hex2dec('aa')) == u(1) && uint8(hex2dec('ff')) == u(2)); unit16_9 Receive y = uint8(u(1) == uint16(hex2dec('aaff')) && u(2) == uint16(hex2dec('ff00')) &&... u(3) == uint16(hex2dec('55f0')) && u(4) == uint16(hex2dec('aaaa')) &&... u(5) == uint16(hex2dec('ffff')) && u(6) == uint16(hex2dec('f520')) &&... u(7) == uint16(hex2dec('aabc')) && u(8) == uint16(hex2dec('ffed')) &&... u(9) == uint16(hex2dec('f052')));
139 u(3)=0; u(4)=0; u(5)=0; u(6)=0; u(7)=0; u(8)=0; u(9)=0; uint32_10 Receive y = uint8(u(1) == uint32(hex2dec('ee33aaff')) && u(2) == uint32(hex2dec('ff001423')) &&... u(3) == uint32(hex2dec('f0d5a400')) && u(4) == uint32(hex2dec('aaaa1111')) &&... u(5) == uint32(hex2dec('ffffbbbb')) && u(6) == uint32(hex2dec('f520aaaa')) &&... u(7) == uint32(hex2dec('aabe4a6c')) && u(8) == uint32(hex2dec('ffed2563')) &&... u(9) == uint32(hex2dec('f052aaaa')) && u(10) == uint32(1234567890)); u(3)=0; u(4)=0; u(5)=0; u(6)=0; u(7)=0; u(8)=0; u(9)=0; u(10)=0; double_2 Receive function [x, y] = fcn(u) x = uint8(u(1)); y = uint8(u(2)); AND function y = fcn(t,u,v,w,z) if(uint8(t) && uint8(z) && uint8(u) && uint8(v) && uint8(w)) y=uint8(1); else y=uint8(0);